diff --git a/syn/components/ps2/software/.metadata/.lock b/syn/components/ps2/software/.metadata/.lock deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/ps2/software/.metadata/.log b/syn/components/ps2/software/.metadata/.log deleted file mode 100644 index bcf1246..0000000 --- a/syn/components/ps2/software/.metadata/.log +++ /dev/null @@ -1,397 +0,0 @@ -!SESSION 2013-09-22 09:51:22.010 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-09-22 09:51:24.447 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY org.eclipse.cdt.core 1 0 2013-09-22 09:54:06.207 -!MESSAGE Indexed 'exe_bsp' (77 sources, 55 headers) in 0.88 sec: 919 declarations; 2,181 references; 113 unresolved inclusions; 5 syntax errors; 193 unresolved names (5.86%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-09-22 09:54:07.524 -!MESSAGE Indexed 'exe' (1 sources, 13 headers) in 0.03 sec: 1 declarations; 1 references; 14 unresolved inclusions; 0 syntax errors; 0 unresolved names (0.00%) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 09:59:36.202 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 09:59:37.717 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:04:27.233 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:04:28.936 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:06:01.961 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:06:22.030 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:06:23.454 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:06:41.531 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:07:02.905 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:07:04.537 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:12:04.114 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:12:05.543 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:13:58.479 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:14:00.095 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:14:59.053 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:15:00.536 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:17:19.219 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:17:20.698 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:18:44.589 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:19:04.659 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:19:06.196 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:20:54.160 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:20:55.729 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:25:51.530 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:25:53.130 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:26:30.377 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:26:50.444 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:26:51.928 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:31:59.849 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:32:19.914 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:32:21.376 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:37:03.285 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:37:05.022 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:40:29.033 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:40:49.103 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:40:50.535 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:41:53.153 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:41:54.760 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:59:50.674 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 10:59:52.298 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:14:40.292 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:14:41.865 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:16:32.957 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:16:34.627 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:33.243 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:33.665 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:35.273 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:42.981 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:43.326 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:17:44.936 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:08.359 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:08.855 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:10.506 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:24.745 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:25.160 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:18:26.723 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:32:51.668 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:32:52.020 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:32:53.597 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:33:06.759 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:33:06.777 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 11:33:08.178 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:28:33.333 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:28:33.350 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:28:34.726 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:30:17.206 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:30:17.221 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:30:18.597 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:45:29.894 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:45:29.909 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:45:31.282 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:56:12.801 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:56:12.817 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 12:56:14.192 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 14:52:45.944 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 14:52:45.960 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 14:52:47.334 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:06:40.122 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:06:40.138 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:06:41.513 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:33:08.777 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:33:08.793 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:33:10.168 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:35:35.554 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:35:35.570 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:35:36.941 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:44:03.073 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:44:03.088 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 15:44:04.461 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:05:03.966 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:05:03.981 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:05:05.355 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:13:55.598 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:13:55.613 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:13:56.987 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:17:59.246 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:17:59.262 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:18:00.638 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:18:46.580 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:18:46.597 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:18:48.094 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:20:29.271 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:20:29.287 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:20:31.740 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:21:08.179 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:21:08.194 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:21:09.568 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:28:07.672 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:28:07.689 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 17:28:09.067 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:04:28.668 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:04:28.683 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:04:30.058 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:12:51.483 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:12:51.498 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:12:52.870 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:13:12.074 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:13:12.090 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:13:13.464 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:17:27.470 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:17:27.486 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-09-22 18:17:28.856 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/ps2/software/exe/exe.elf] diff --git a/syn/components/ps2/software/.metadata/.mylyn/repositories.xml.zip b/syn/components/ps2/software/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index 9046cc0..0000000 Binary files a/syn/components/ps2/software/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/.log b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/.log deleted file mode 100644 index d05dbfa..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/.log +++ /dev/null @@ -1 +0,0 @@ -*** SESSION Sep 22, 2013 09:51:53.35 ------------------------------------------- diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1379836447488.pdom b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1379836447488.pdom deleted file mode 100644 index c547361..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1379836447488.pdom and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1379836445259.pdom b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1379836445259.pdom deleted file mode 100644 index cde3fdd..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1379836445259.pdom and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc deleted file mode 100644 index b81f0d7..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc +++ /dev/null @@ -1,618 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc deleted file mode 100644 index 64c1e44..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml deleted file mode 100644 index d8d4735..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml +++ /dev/null @@ -1,8 +0,0 @@ - -
- -
-
-
-
-
diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log deleted file mode 100644 index 2301803..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log +++ /dev/null @@ -1,19 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log deleted file mode 100644 index 6abdd49..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log +++ /dev/null @@ -1,180 +0,0 @@ - -**** Build of configuration Nios II for project exe_bsp **** - -make all -Compiling alt_alarm_start.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_alarm_start.o HAL/src/alt_alarm_start.c -Compiling alt_busy_sleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_busy_sleep.o HAL/src/alt_busy_sleep.c -Compiling alt_close.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_close.o HAL/src/alt_close.c -Compiling alt_dcache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush.o HAL/src/alt_dcache_flush.c -Compiling alt_dcache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_all.o HAL/src/alt_dcache_flush_all.c -Compiling alt_dcache_flush_no_writeback.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_no_writeback.o HAL/src/alt_dcache_flush_no_writeback.c -Compiling alt_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev.o HAL/src/alt_dev.c -Compiling alt_dev_llist_insert.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev_llist_insert.o HAL/src/alt_dev_llist_insert.c -Compiling alt_dma_rxchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_rxchan_open.o HAL/src/alt_dma_rxchan_open.c -Compiling alt_dma_txchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_txchan_open.o HAL/src/alt_dma_txchan_open.c -Compiling alt_do_ctors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_ctors.o HAL/src/alt_do_ctors.c -Compiling alt_do_dtors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_dtors.o HAL/src/alt_do_dtors.c -Compiling alt_env_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_env_lock.o HAL/src/alt_env_lock.c -Compiling alt_environ.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_environ.o HAL/src/alt_environ.c -Compiling alt_errno.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_errno.o HAL/src/alt_errno.c -Compiling alt_exception_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_entry.o HAL/src/alt_exception_entry.S -Compiling alt_exception_muldiv.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_muldiv.o HAL/src/alt_exception_muldiv.S -Compiling alt_exception_trap.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_trap.o HAL/src/alt_exception_trap.S -Compiling alt_execve.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_execve.o HAL/src/alt_execve.c -Compiling alt_exit.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_exit.o HAL/src/alt_exit.c -Compiling alt_fcntl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fcntl.o HAL/src/alt_fcntl.c -Compiling alt_fd_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_lock.o HAL/src/alt_fd_lock.c -Compiling alt_fd_unlock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_unlock.o HAL/src/alt_fd_unlock.c -Compiling alt_find_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_dev.o HAL/src/alt_find_dev.c -Compiling alt_find_file.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_file.o HAL/src/alt_find_file.c -Compiling alt_flash_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_flash_dev.o HAL/src/alt_flash_dev.c -Compiling alt_fork.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fork.o HAL/src/alt_fork.c -Compiling alt_fs_reg.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fs_reg.o HAL/src/alt_fs_reg.c -Compiling alt_fstat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fstat.o HAL/src/alt_fstat.c -Compiling alt_get_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_get_fd.o HAL/src/alt_get_fd.c -Compiling alt_getchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getchar.o HAL/src/alt_getchar.c -Compiling alt_getpid.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getpid.o HAL/src/alt_getpid.c -Compiling alt_gettod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gettod.o HAL/src/alt_gettod.c -Compiling alt_gmon.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gmon.o HAL/src/alt_gmon.c -Compiling alt_icache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush.o HAL/src/alt_icache_flush.c -Compiling alt_icache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush_all.o HAL/src/alt_icache_flush_all.c -Compiling alt_iic.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic.o HAL/src/alt_iic.c -Compiling alt_iic_isr_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic_isr_register.o HAL/src/alt_iic_isr_register.c -Compiling alt_instruction_exception_entry.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_entry.o HAL/src/alt_instruction_exception_entry.c -Compiling alt_instruction_exception_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_register.o HAL/src/alt_instruction_exception_register.c -Compiling alt_io_redirect.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_io_redirect.o HAL/src/alt_io_redirect.c -Compiling alt_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_ioctl.o HAL/src/alt_ioctl.c -Compiling alt_irq_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_irq_entry.o HAL/src/alt_irq_entry.S -Compiling alt_irq_handler.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_handler.o HAL/src/alt_irq_handler.c -Compiling alt_irq_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_register.o HAL/src/alt_irq_register.c -Compiling alt_irq_vars.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_vars.o HAL/src/alt_irq_vars.c -Compiling alt_isatty.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_isatty.o HAL/src/alt_isatty.c -Compiling alt_kill.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_kill.o HAL/src/alt_kill.c -Compiling alt_link.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_link.o HAL/src/alt_link.c -Compiling alt_load.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_load.o HAL/src/alt_load.c -Compiling alt_log_macro.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_log_macro.o HAL/src/alt_log_macro.S -Compiling alt_log_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_log_printf.o HAL/src/alt_log_printf.c -Compiling alt_lseek.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_lseek.o HAL/src/alt_lseek.c -Compiling alt_main.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_main.o HAL/src/alt_main.c -Compiling alt_malloc_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_malloc_lock.o HAL/src/alt_malloc_lock.c -Compiling alt_mcount.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_mcount.o HAL/src/alt_mcount.S -Compiling alt_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_open.o HAL/src/alt_open.c -Compiling alt_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_printf.o HAL/src/alt_printf.c -Compiling alt_putchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putchar.o HAL/src/alt_putchar.c -Compiling alt_putstr.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putstr.o HAL/src/alt_putstr.c -Compiling alt_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_read.o HAL/src/alt_read.c -Compiling alt_release_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_release_fd.o HAL/src/alt_release_fd.c -Compiling alt_remap_cached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_cached.o HAL/src/alt_remap_cached.c -Compiling alt_remap_uncached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_uncached.o HAL/src/alt_remap_uncached.c -Compiling alt_rename.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_rename.o HAL/src/alt_rename.c -Compiling alt_sbrk.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_sbrk.o HAL/src/alt_sbrk.c -Compiling alt_settod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_settod.o HAL/src/alt_settod.c -Compiling alt_software_exception.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_software_exception.o HAL/src/alt_software_exception.S -Compiling alt_stat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_stat.o HAL/src/alt_stat.c -Compiling alt_tick.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_tick.o HAL/src/alt_tick.c -Compiling alt_times.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_times.o HAL/src/alt_times.c -Compiling alt_uncached_free.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_free.o HAL/src/alt_uncached_free.c -Compiling alt_uncached_malloc.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_malloc.o HAL/src/alt_uncached_malloc.c -Compiling alt_unlink.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_unlink.o HAL/src/alt_unlink.c -Compiling alt_usleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_usleep.o HAL/src/alt_usleep.c -Compiling alt_wait.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_wait.o HAL/src/alt_wait.c -Compiling alt_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_write.o HAL/src/alt_write.c -Compiling altera_nios2_qsys_irq.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/altera_nios2_qsys_irq.o HAL/src/altera_nios2_qsys_irq.c -Compiling crt0.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/crt0.o HAL/src/crt0.S -Compiling alt_sys_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/alt_sys_init.o alt_sys_init.c -Compiling altera_avalon_jtag_uart_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_fd.o drivers/src/altera_avalon_jtag_uart_fd.c -Compiling altera_avalon_jtag_uart_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_init.o drivers/src/altera_avalon_jtag_uart_init.c -Compiling altera_avalon_jtag_uart_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o drivers/src/altera_avalon_jtag_uart_ioctl.c -Compiling altera_avalon_jtag_uart_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_read.o drivers/src/altera_avalon_jtag_uart_read.c -Compiling altera_avalon_jtag_uart_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_write.o drivers/src/altera_avalon_jtag_uart_write.c -Creating libhal_bsp.a... -rm -f -f libhal_bsp.a -nios2-elf-ar -src libhal_bsp.a obj/HAL/src/alt_alarm_start.o obj/HAL/src/alt_busy_sleep.o obj/HAL/src/alt_close.o obj/HAL/src/alt_dcache_flush.o obj/HAL/src/alt_dcache_flush_all.o obj/HAL/src/alt_dcache_flush_no_writeback.o obj/HAL/src/alt_dev.o obj/HAL/src/alt_dev_llist_insert.o obj/HAL/src/alt_dma_rxchan_open.o obj/HAL/src/alt_dma_txchan_open.o obj/HAL/src/alt_do_ctors.o obj/HAL/src/alt_do_dtors.o obj/HAL/src/alt_env_lock.o obj/HAL/src/alt_environ.o obj/HAL/src/alt_errno.o obj/HAL/src/alt_exception_entry.o obj/HAL/src/alt_exception_muldiv.o obj/HAL/src/alt_exception_trap.o obj/HAL/src/alt_execve.o obj/HAL/src/alt_exit.o obj/HAL/src/alt_fcntl.o obj/HAL/src/alt_fd_lock.o obj/HAL/src/alt_fd_unlock.o obj/HAL/src/alt_find_dev.o obj/HAL/src/alt_find_file.o obj/HAL/src/alt_flash_dev.o obj/HAL/src/alt_fork.o obj/HAL/src/alt_fs_reg.o obj/HAL/src/alt_fstat.o obj/HAL/src/alt_get_fd.o obj/HAL/src/alt_getchar.o obj/HAL/src/alt_getpid.o obj/HAL/src/alt_gettod.o obj/HAL/src/alt_gmon.o obj/HAL/src/alt_icache_flush.o obj/HAL/src/alt_icache_flush_all.o obj/HAL/src/alt_iic.o obj/HAL/src/alt_iic_isr_register.o obj/HAL/src/alt_instruction_exception_entry.o obj/HAL/src/alt_instruction_exception_register.o obj/HAL/src/alt_io_redirect.o obj/HAL/src/alt_ioctl.o obj/HAL/src/alt_irq_entry.o obj/HAL/src/alt_irq_handler.o obj/HAL/src/alt_irq_register.o obj/HAL/src/alt_irq_vars.o obj/HAL/src/alt_isatty.o obj/HAL/src/alt_kill.o obj/HAL/src/alt_link.o obj/HAL/src/alt_load.o obj/HAL/src/alt_log_macro.o obj/HAL/src/alt_log_printf.o obj/HAL/src/alt_lseek.o obj/HAL/src/alt_main.o obj/HAL/src/alt_malloc_lock.o obj/HAL/src/alt_mcount.o obj/HAL/src/alt_open.o obj/HAL/src/alt_printf.o obj/HAL/src/alt_putchar.o obj/HAL/src/alt_putstr.o obj/HAL/src/alt_read.o obj/HAL/src/alt_release_fd.o obj/HAL/src/alt_remap_cached.o obj/HAL/src/alt_remap_uncached.o obj/HAL/src/alt_rename.o obj/HAL/src/alt_sbrk.o obj/HAL/src/alt_settod.o obj/HAL/src/alt_software_exception.o obj/HAL/src/alt_stat.o obj/HAL/src/alt_tick.o obj/HAL/src/alt_times.o obj/HAL/src/alt_uncached_free.o obj/HAL/src/alt_uncached_malloc.o obj/HAL/src/alt_unlink.o obj/HAL/src/alt_usleep.o obj/HAL/src/alt_wait.o obj/HAL/src/alt_write.o obj/HAL/src/altera_nios2_qsys_irq.o obj/HAL/src/crt0.o obj/alt_sys_init.o obj/drivers/src/altera_avalon_jtag_uart_fd.o obj/drivers/src/altera_avalon_jtag_uart_init.o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o obj/drivers/src/altera_avalon_jtag_uart_read.o obj/drivers/src/altera_avalon_jtag_uart_write.o -[BSP build complete] - -**** Build Finished **** diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log deleted file mode 100644 index 7ab4d0b..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log +++ /dev/null @@ -1,751 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 10 KBytes program size (code + initialized data). -Info: 21 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:6: warning: implicit declaration of function 'IORD' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -obj/default/main.o: In function `main': -/home/alek/aktualne/ps2/software/exe/main.c:6: undefined reference to `IORD' -collect2: ld returned 1 exit status -make: *** [exe.elf] Error 1 - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:14: warning: implicit declaration of function 'IORD_DIRECT' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -obj/default/main.o: In function `main': -/home/alek/aktualne/ps2/software/exe/main.c:14: undefined reference to `IORD_DIRECT' -collect2: ld returned 1 exit status -make: *** [exe.elf] Error 1 - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -main.c:9: warning: unused variable 'impl' -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:9: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:9: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:9: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:9: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:9: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -main.c:13: warning: unused variable 'impl' -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:15: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:15: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:15: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:15: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:17: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -main.c:19: warning: unused variable 'impl' -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:19: warning: unused variable 'impl' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O0 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/ps2" --sopcinfo /home/alek/aktualne/ps2/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/f029b138992300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/f029b138992300131780818a8e3fb998 deleted file mode 100644 index ec603b0..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/f029b138992300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1a/700d68d7852300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1a/700d68d7852300131780818a8e3fb998 deleted file mode 100644 index 8e08d8a..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1a/700d68d7852300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - printf("status: %02x\n", status); - usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1d/c00d41999a2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1d/c00d41999a2300131780818a8e3fb998 deleted file mode 100644 index ba36b50..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1d/c00d41999a2300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF5); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1f/c0bb3ee4712300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1f/c0bb3ee4712300131780818a8e3fb998 deleted file mode 100644 index 499ea0d..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/1f/c0bb3ee4712300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = (IORD_8DIRECT(PS2_0_BASE, 4) & 1)) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - printf("status: %02x\n", status); - usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2/902ad669612300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2/902ad669612300131780818a8e3fb998 deleted file mode 100644 index a3ee3e7..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2/902ad669612300131780818a8e3fb998 +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/22/40bdd71e5e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/22/40bdd71e5e2300131780818a8e3fb998 deleted file mode 100644 index fecacb5..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/22/40bdd71e5e2300131780818a8e3fb998 +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int status = IORD(PIO_0_BASE, 0); - printf("Port: %x\n", status); - usleep(1000000); - - if() - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/20a0a463612300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/20a0a463612300131780818a8e3fb998 deleted file mode 100644 index 43ea8ba..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/20a0a463612300131780818a8e3fb998 +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/c01ed3ce5d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/c01ed3ce5d2300131780818a8e3fb998 deleted file mode 100644 index f755d4c..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/c01ed3ce5d2300131780818a8e3fb998 +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -#include -#include - -int main() { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/003dd6db852300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/003dd6db852300131780818a8e3fb998 deleted file mode 100644 index 0bd88b7..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/003dd6db852300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d01b1396992300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d01b1396992300131780818a8e3fb998 deleted file mode 100644 index 9473d91..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d01b1396992300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/a002f558982300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/a002f558982300131780818a8e3fb998 deleted file mode 100644 index 32b05f0..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/a002f558982300131780818a8e3fb998 +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PIO_0_BASE, 4, 0x60); - IOWR_8DIRECT(PIO_0) - - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e0b342a0622300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e0b342a0622300131780818a8e3fb998 deleted file mode 100644 index 7dba7ef..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/4f/e0b342a0622300131780818a8e3fb998 +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = (IORD_8DIRECT(PS2_0_BASE, 4) & 1)) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0d5b5449a2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0d5b5449a2300131780818a8e3fb998 deleted file mode 100644 index 2e9a072..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/56/b0d5b5449a2300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/40a3be71a22300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/40a3be71a22300131780818a8e3fb998 deleted file mode 100644 index 5a610ba..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/40a3be71a22300131780818a8e3fb998 +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - int status = IORD_8DIRECT(PS2_0_BASE, 4); - - if(impl & 0x02) { //mouse - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - if(impl & 0x02) { //keyboard - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6/c044e7165e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6/c044e7165e2300131780818a8e3fb998 deleted file mode 100644 index db02a6d..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6/c044e7165e2300131780818a8e3fb998 +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - usleep(1000000); - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/60/0009e4555f2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/60/0009e4555f2300131780818a8e3fb998 deleted file mode 100644 index 18d0295..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/60/0009e4555f2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Impl: %02x\n", impl); - usleep(1000000); - - if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/68/5048c0be5d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/68/5048c0be5d2300131780818a8e3fb998 deleted file mode 100644 index 49e7c66..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/68/5048c0be5d2300131780818a8e3fb998 +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#include -#include - -int main() { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6b/70cf0e38992300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6b/70cf0e38992300131780818a8e3fb998 deleted file mode 100644 index f9ee0b3..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/6b/70cf0e38992300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/c0953aac602300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/c0953aac602300131780818a8e3fb998 deleted file mode 100644 index 10776d5..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/c0953aac602300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/3008db445e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/3008db445e2300131780818a8e3fb998 deleted file mode 100644 index 3e8d25f..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/3008db445e2300131780818a8e3fb998 +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int status = IORD(PIO_0_BASE, 0); - printf("Port: %x\n", status); - usleep(1000000); - - if(status & 0x1) { - - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7f/308de917982300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7f/308de917982300131780818a8e3fb998 deleted file mode 100644 index e0a0ba4..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/7f/308de917982300131780818a8e3fb998 +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PIO_0_BASE, 4, ); - - - - int impl = IORD_8DIRECT(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/80/50f33261a22300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/80/50f33261a22300131780818a8e3fb998 deleted file mode 100644 index ebdd6a2..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/80/50f33261a22300131780818a8e3fb998 +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - - if(impl & 0x02) { //mouse - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/83/c05f2907982300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/83/c05f2907982300131780818a8e3fb998 deleted file mode 100644 index ad0685d..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/83/c05f2907982300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/84/a07fd0baa12300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/84/a07fd0baa12300131780818a8e3fb998 deleted file mode 100644 index b301857..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/84/a07fd0baa12300131780818a8e3fb998 +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF5); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/89/30b12a71612300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/89/30b12a71612300131780818a8e3fb998 deleted file mode 100644 index a9724d3..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/89/30b12a71612300131780818a8e3fb998 +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = (IORD_8DIRECT(PS2_0_BASE, 4) & 1)) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8b/906705f7712300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8b/906705f7712300131780818a8e3fb998 deleted file mode 100644 index c399de9..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8b/906705f7712300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1)) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - printf("status: %02x\n", status); - usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8e/d07d46bca12300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8e/d07d46bca12300131780818a8e3fb998 deleted file mode 100644 index 4601d75..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8e/d07d46bca12300131780818a8e3fb998 +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF5); - - while(1) { - - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/70148dcc5f2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/70148dcc5f2300131780818a8e3fb998 deleted file mode 100644 index 8e19453..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/70148dcc5f2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/95/50bb2cd05d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/95/50bb2cd05d2300131780818a8e3fb998 deleted file mode 100644 index 503005c..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/95/50bb2cd05d2300131780818a8e3fb998 +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - usleep(1000); - } - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/96/801ec734992300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/96/801ec734992300131780818a8e3fb998 deleted file mode 100644 index 68ebc7e..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/96/801ec734992300131780818a8e3fb998 +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c046118c5d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c046118c5d2300131780818a8e3fb998 deleted file mode 100644 index fba3ec7..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c046118c5d2300131780818a8e3fb998 +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include - -int main() { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a038b47f9a2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a038b47f9a2300131780818a8e3fb998 deleted file mode 100644 index 6a0d485..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a038b47f9a2300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF5); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a0acf8935f2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a0acf8935f2300131780818a8e3fb998 deleted file mode 100644 index c1321de..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/a0acf8935f2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - if(impl != 0x0C) printf("Impl: %02x\n", impl); - usleep(1000000); - - if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a3/b0503de85d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a3/b0503de85d2300131780818a8e3fb998 deleted file mode 100644 index a901da3..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/a3/b0503de85d2300131780818a8e3fb998 +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - usleep(1000); - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b6/a06d8ccc5e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b6/a06d8ccc5e2300131780818a8e3fb998 deleted file mode 100644 index b916a91..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b6/a06d8ccc5e2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Impl: %02x\n", impl); - usleep(1000000); - - if(impl & 0x1) { - while((IORD(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b9/d0229d6fa22300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b9/d0229d6fa22300131780818a8e3fb998 deleted file mode 100644 index 4930c9c..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/b9/d0229d6fa22300131780818a8e3fb998 +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - int status = IORD_8DIRECT(PS2_0_BASE, 4); - - if(impl & 0x02) { //mouse - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - - while(((status = ) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ba/3007f3825e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ba/3007f3825e2300131780818a8e3fb998 deleted file mode 100644 index f428b22..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ba/3007f3825e2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int status = IORD(PIO_0_BASE, 0); - printf("Port: %02x\n", status); - usleep(1000000); - - if(status & 0x1) { - while((IORD(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c6/30552e775e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c6/30552e775e2300131780818a8e3fb998 deleted file mode 100644 index 8e825cc..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c6/30552e775e2300131780818a8e3fb998 +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int status = IORD(PIO_0_BASE, 0); - printf("Port: %02x\n", status); - usleep(1000000); - - if(status & 0x1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c9/c00eaf1b9a2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c9/c00eaf1b9a2300131780818a8e3fb998 deleted file mode 100644 index 7c83b1d..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/c9/c00eaf1b9a2300131780818a8e3fb998 +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xEA); - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cb/006625655c2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cb/006625655c2300131780818a8e3fb998 deleted file mode 100755 index 9311c92..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cb/006625655c2300131780818a8e3fb998 +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# This script creates the hello_world application in this directory. - - -BSP_DIR=../exe_bsp -QUARTUS_PROJECT_DIR=../../ -NIOS2_APP_GEN_ARGS="--elf-name exe.elf --set OBJDUMP_INCLUDE_SOURCE 1 --src-files hello_world.c" - - -# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set. -# This variable is required for the command line tools to execute correctly. -if [ -z "${SOPC_KIT_NIOS2}" ] -then - echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set! - exit 1 -fi - - -# Also make sure that the APP has not been created already. Check for -# existence of Makefile in the app directory -if [ -f ./Makefile ] -then - echo Application has already been created! Delete Makefile if you want to create a new application makefile - exit 1 -fi - - -# We are selecting hal_default bsp because it supports this application. -# Check to see if the hal_default has already been generated by checking for -# existence of the public.mk file. If not, we need to run -# create-this-bsp file to generate the bsp. -if [ ! -f ${BSP_DIR}/public.mk ]; then - # Since BSP doesn't exist, create the BSP - # Pass any command line arguments passed to this script to the BSP. - pushd ${BSP_DIR} >> /dev/null - ./create-this-bsp "$@" || { - echo "create-this-bsp failed" - exit 1 - } - popd >> /dev/null -fi - - -# Don't run make if create-this-app script is called with --no-make arg -SKIP_MAKE= -while [ $# -gt 0 ] -do - case "$1" in - --no-make) - SKIP_MAKE=1 - ;; - esac - shift -done - - -# Now we also need to go copy the sources for this application to the -# local directory. -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || { - echo "failed during copying example source files" - exit 1 -} - -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || { - echo "failed copying readme file" -} - -if [ -d "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" ] -then - cp -RL "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" . || { - echo "failed during copying project support files" - exit 1 - } -fi - -chmod -R +w . || { - echo "failed during changing file permissions" - exit 1 -} - -cmd="nios2-app-generate-makefile --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}" - -echo "create-this-app: Running \"${cmd}\"" -$cmd || { - echo "nios2-app-generate-makefile failed" - exit 1 -} - -if [ -z "$SKIP_MAKE" ]; then - cmd="make" - - echo "create-this-app: Running \"$cmd\"" - $cmd || { - echo "make failed" - exit 1 - } - - echo - echo "To download and run the application:" - echo " 1. Make sure the board is connected to the system." - echo " 2. Run 'nios2-configure-sof ' to configure the FPGA with the hardware design." - echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell." - echo " 4. Run 'make download-elf' from the application directory." - echo - echo "To debug the application:" - echo " Import the project into Nios II Software Build Tools for Eclipse." - echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information." - echo - echo -e "" -fi - - -exit 0 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b02a3b76a22300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b02a3b76a22300131780818a8e3fb998 deleted file mode 100644 index 3d081eb..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b02a3b76a22300131780818a8e3fb998 +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - int status = IORD_8DIRECT(PS2_0_BASE, 4); - - if(impl & 0x02) { //mouse - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - if(impl & 0x01) { //keyboard - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("mouse: %02x, status: %02x\n", scancode, status); - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d1/10c041045f2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d1/10c041045f2300131780818a8e3fb998 deleted file mode 100644 index 65baa62..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d1/10c041045f2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Impl: %02x\n", impl); - usleep(1000000); - - if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d6/90f1b9df5e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d6/90f1b9df5e2300131780818a8e3fb998 deleted file mode 100644 index f073f29..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d6/90f1b9df5e2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Impl: %02x\n", impl); - usleep(1000000); - - if(impl & 0x1) { - while((IORD_DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d8/2011ea615c2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d8/2011ea615c2300131780818a8e3fb998 deleted file mode 100644 index a04d9c6..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/d8/2011ea615c2300131780818a8e3fb998 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * "Hello World" example. - * - * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on - * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example - * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT - * device in your system's hardware. - * The memory footprint of this hosted application is ~69 kbytes by default - * using the standard reference design. - * - * For a reduced footprint version of this template, and an explanation of how - * to reduce the memory footprint for a given application, see the - * "small_hello_world" template. - * - */ - -#include - -int main() -{ - printf("Hello from Nios II!\n"); - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0396d0d982300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0396d0d982300131780818a8e3fb998 deleted file mode 100644 index c300cbb..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0396d0d982300131780818a8e3fb998 +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - IOWR_8DIRECT(); - - - - int impl = IORD_8DIRECT(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e0/d0b11edda12300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e0/d0b11edda12300131780818a8e3fb998 deleted file mode 100644 index 9fe546e..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e0/d0b11edda12300131780818a8e3fb998 +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF5); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e2/308fe361612300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e2/308fe361612300131780818a8e3fb998 deleted file mode 100644 index 668b2af..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e2/308fe361612300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - while((IORD_8DIRECT(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e4/40019952a22300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e4/40019952a22300131780818a8e3fb998 deleted file mode 100644 index eb703f1..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e4/40019952a22300131780818a8e3fb998 +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -#include -#include - -int main() { - - IOWR_8DIRECT(PS2_0_BASE, 4, 0x60); - IOWR_8DIRECT(PS2_0_BASE, 0, 0x03); - - usleep(100000); - - IOWR_8DIRECT(PS2_0_BASE, 4, 0xD4); - IOWR_8DIRECT(PS2_0_BASE, 0, 0xF4); - - while(1) { - - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while(((status = IORD_8DIRECT(PS2_0_BASE, 4)) & 1) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - //if(status != 0) printf("status: %02x\n", status); - //usleep(1000000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e8/c0f64d8b5d2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e8/c0f64d8b5d2300131780818a8e3fb998 deleted file mode 100644 index 154dd1a..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e8/c0f64d8b5d2300131780818a8e3fb998 +++ /dev/null @@ -1,9 +0,0 @@ - -#include -#include - -int main() { - printf("Port: %x\n", IORD(PIO_0_BASE, 0)); - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/60bd7cbe622300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/60bd7cbe622300131780818a8e3fb998 deleted file mode 100644 index 5e85fe8..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/60bd7cbe622300131780818a8e3fb998 +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - //if(impl != 0x0C) printf("Impl: %02x\n", impl); - //usleep(1000000); - - //if(impl & 0x1) { - int status; - while((status = (IORD_8DIRECT(PS2_0_BASE, 4) & 1)) == 1) { - int scancode = IORD_8DIRECT(PS2_0_BASE, 0); - printf("code: %02x, status: %02x\n", scancode, status); - } - printf("status: %02x\n", status); - usleep(10000); - //} - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ec/a08532875e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ec/a08532875e2300131780818a8e3fb998 deleted file mode 100644 index d9f7c81..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/ec/a08532875e2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Impl: %02x\n", impl); - usleep(1000000); - - if(status & 0x1) { - while((IORD(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4018b7685c2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4018b7685c2300131780818a8e3fb998 deleted file mode 100644 index 7d0742f..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4018b7685c2300131780818a8e3fb998 +++ /dev/null @@ -1,26 +0,0 @@ -Readme - Hello World Software Example - -DESCRIPTION: -Simple program that prints "Hello from Nios II" - -The memory footprint of this hosted application is intended to be small (under 100 kbytes) by default -using a standard reference deisgn. - -For an even smaller, reduced footprint version of this template, and an explanation of how -to reduce the memory footprint for a given application, see the -"small_hello_world" template. - - -PERIPHERALS USED: -This example exercises the following peripherals: -- STDOUT device (UART or JTAG UART) - -SOFTWARE SOURCE FILES: -This example includes the following software source files: -- hello_world.c: Everyone needs a Hello World program, right? - -BOARD/HOST REQUIREMENTS: -This example requires only a JTAG connection with a Nios Development board. If -the host communication settings are changed from JTAG UART (default) to use a -conventional UART, a serial cable between board DB-9 connector and the host is -required. diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a04434855e2300131780818a8e3fb998 b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a04434855e2300131780818a8e3fb998 deleted file mode 100644 index 4fa6914..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a04434855e2300131780818a8e3fb998 +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include -#include - -int main() { - while(1) { - int impl = IORD(PIO_0_BASE, 0); - printf("Port: %02x\n", impl); - usleep(1000000); - - if(status & 0x1) { - while((IORD(PS2_0_BASE, 4) & 1) == 1) { - int scancode = IORD(PS2_0_BASE, 0); - printf("code: %02x\n", scancode); - } - } - } - - return 0; -} diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index deleted file mode 100644 index 60b40e9..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index deleted file mode 100644 index 4ff0224..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index deleted file mode 100644 index 7f98788..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index deleted file mode 100644 index 198c4de..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index f3b5ef9..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version deleted file mode 100644 index 6b2aaa7..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree deleted file mode 100644 index 7f55ae5..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources deleted file mode 100644 index 37f7b97..0000000 Binary files a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and /dev/null differ diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs deleted file mode 100644 index f14e9fb..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -newSoftwareExampleWizardPage.defaultLocation=/home/alek/aktualne/ps2/software/exe -newSoftwareExampleWizardPage.sopcinfoFile=/home/alek/aktualne/ps2/soc.sopcinfo -newSoftwareExampleWizardPage2.newBspLocation=/home/alek/aktualne/ps2/software/exe_bsp diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs deleted file mode 100644 index b8c9267..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.debug.core.cDebug.default_source_containers=\n\n\n\n\n\n\n\n diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index 17e09e1..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -properties/exe.null.201778649/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1369921547=\#\n\#Sun Sep 22 18\:17\:27 CEST 2013\ncdt.managedbuild.tool.gnu.archiver.base.122494800\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1829580581\=\\\#\\n\\\#Sun Sep 22 09\\\:55\\\:35 CEST 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.2038302058\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1369921547\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.448931088\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.assembler.base.207496831\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.1884322564\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1128719961\=\\\#\\n\\\#Sun Sep 22 09\\\:55\\\:35 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.708181716\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.libs.516676118\=\\\#\\n\\\#Sun Sep 22 09\\\:55\\\:35 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.1689059671\=\\\#\\n\\\#Sun Sep 22 09\\\:55\\\:35 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.1998137834\=\\\#\\n\\\#Sun Sep 22 09\\\:55\\\:35 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.131532781\=\\\#\\n\\\#Sun Sep 22 18\\\:17\\\:27 CEST 2013\\nrebuildState\\\=false\\n\n -properties/exe_bsp.null.1804543647/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.311380379=\#\n\#Sun Sep 22 09\:57\:27 CEST 2013\ncdt.managedbuild.tool.gnu.archiver.base.571045014\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1169055479\=\\\#\\n\\\#Sun Sep 22 09\\\:54\\\:07 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.libs.1669752478\=\\\#\\n\\\#Sun Sep 22 09\\\:54\\\:07 CEST 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.197030142\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.605868123\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1287561521\=\\\#\\n\\\#Sun Sep 22 09\\\:54\\\:07 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.1481904286\=\\\#\\n\\\#Sun Sep 22 09\\\:54\\\:07 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.932025512\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.assembler.base.671679283\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.230699969\=\\\#\\n\\\#Sun Sep 22 09\\\:54\\\:07 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.527924868\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.1415131332\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrebuildState\\\=false\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.311380379\=\\\#\\n\\\#Sun Sep 22 09\\\:57\\\:27 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\n diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs deleted file mode 100644 index 0451f54..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.cdt.ui.run.count.3_3_0=1 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs deleted file mode 100644 index cbfe61a..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs +++ /dev/null @@ -1,5 +0,0 @@ -content_assist_disabled_computers=org.eclipse.cdt.ui.parserProposalCategory\u0000org.eclipse.cdt.ui.textProposalCategory\u0000 -eclipse.preferences.version=1 -spelling_locale_initialized=true -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index a7fb09f..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -description.autobuilding=false -eclipse.preferences.version=1 -version=1 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs deleted file mode 100644 index 57e3b77..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug;org.eclipse.cdt.cdi.launch.localCLaunch,run -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.remoteApplicationLaunchType=org.eclipse.rse.remotecdt.dsf.debug,debug -eclipse.preferences.version=1 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs deleted file mode 100644 index a2917e5..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n -preferredTargets=org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget| diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs deleted file mode 100644 index c2d6b76..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.epp.usagedata.recording.last-upload=1379836316706 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs deleted file mode 100644 index 43e97e4..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -mylyn.attention.migrated=true diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs deleted file mode 100644 index 8d462a6..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs deleted file mode 100644 index f9e585b..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -pref_first_startup=false diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs deleted file mode 100644 index 56cd496..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.team.ui.first_time=false diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs deleted file mode 100644 index 031cfa6..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -lineNumberRuler=true -overviewRuler_migration=migrated_3.1 -printMargin=true -spacesForTabs=true diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index cbf368c..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,5 +0,0 @@ -PROBLEMS_FILTERS_MIGRATE=true -eclipse.preferences.version=1 -platformState=1379836282949 -quickStart=false -tipsAndTricks=true diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index 08076f2..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -showIntro=false diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs deleted file mode 100644 index 68b875a..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ /dev/null @@ -1,2 +0,0 @@ -ENABLED_DECORATORS=com.altera.sbtgui.project.decorator.bsp\:true,com.altera.sbtgui.project.nios2builddecorator\:true,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false, -eclipse.preferences.version=1 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch deleted file mode 100644 index e6d9c58..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml deleted file mode 100644 index 1ffd61e..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- - - - - - -
-
diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 795c14e..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv deleted file mode 100644 index 096f789..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1379836315644 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1379836315645 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1379836315645 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1379836315645 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1379836315645 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1379836315646 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1379836315646 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1379836315646 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1379836315646 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1379836315646 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1379836315646 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1379836315646 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1379836315646 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1379836315646 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1379836315646 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1379836315646 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1379836315646 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1379836315647 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1379836315647 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1379836315647 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1379836315647 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1379836315647 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1379836315647 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1379836315647 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1379836315647 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1379836315647 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1379836315647 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1379836315647 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1379836315647 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1379836315647 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1379836315648 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1379836315648 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1379836315648 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1379836315648 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1379836315648 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1379836315648 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1379836315648 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1379836315649 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1379836315649 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1379836315649 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1379836315649 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1379836315649 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1379836315649 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1379836315649 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1379836315649 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1379836315649 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1379836315649 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1379836315649 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1379836315649 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1379836315649 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1379836315649 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1379836315649 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1379836315650 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1379836315650 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1379836315650 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1379836315650 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1379836315650 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1379836315650 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1379836315650 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1379836315650 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1379836315650 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1379836315650 -started,bundle,org.eclipse.ui.intro,3.4.100.v20110425,"org.eclipse.ui.intro",1379836315650 -started,bundle,org.eclipse.ui.intro.universal,3.2.500.v20110510,"org.eclipse.ui.intro.universal",1379836315650 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1379836315650 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1379836315650 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1379836315650 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1379836315650 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1379836315650 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1379836315650 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1379836315650 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1379836315650 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1379836315650 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1379836315651 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1379836315651 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1379836315651 -started,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1379836315651 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1379836315651 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1379836315651 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1379836315651 -os,sysinfo,,,"linux",1379836315654 -arch,sysinfo,,,"x86",1379836315654 -ws,sysinfo,,,"gtk",1379836315654 -locale,sysinfo,,,"en_US",1379836315654 -processors,sysinfo,,,"8",1379836315654 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1379836315654 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1379836315654 -java.specification.name,sysinfo,,,"Java Platform API Specification",1379836315654 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1379836315654 -java.specification.version,sysinfo,,,"1.6",1379836315654 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1379836315654 -java.version,sysinfo,,,"1.6.0_23",1379836315654 -java.vm.info,sysinfo,,,"mixed mode",1379836315654 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1379836315654 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1379836315654 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1379836315654 -java.vm.specification.version,sysinfo,,,"1.0",1379836315654 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1379836315654 -java.vm.version,sysinfo,,,"19.0-b09",1379836315654 -activated,view,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.internal.introview",1379836318958 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379836318961 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1379836324859 -started,bundle,com.altera.sbtgui.integration.jars,13.13.0.132,"com.altera.sbtgui.integration.jars",1379836325122 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836325492 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836326883 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836326892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836370027 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836372632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836374269 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836376534 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836395907 -opened,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379836399892 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1379836399996 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1379836400000 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1379836400000 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1379836400000 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836400157 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1379836445089 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1379836445122 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1379836446565 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836449416 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1379836451647 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1379836451649 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836454522 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836489192 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836494674 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836497414 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836499262 -started,bundle,org.eclipse.core.databinding,1.4.0.I20110111-0800,"org.eclipse.core.databinding",1379836502765 -started,bundle,org.eclipse.core.databinding.property,1.4.0.I20110222-0800,"org.eclipse.core.databinding.property",1379836502771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1379836522397 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836522404 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836522691 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836528480 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836532167 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836536037 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836542705 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1379836544363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379836544363 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836544371 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836544407 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836545137 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836547895 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1379836549243 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379836549243 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836549249 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836553766 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1379836555229 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379836555229 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836555236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836560835 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836568471 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836569413 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836569482 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836569551 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836569803 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1379836569870 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.toggleOverwrite",1379836573797 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379836573816 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.toggleOverwrite",1379836574365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379836574661 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379836575475 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379836576495 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836581473 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836586803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836589230 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1379836595615 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836595624 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836598378 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379836619351 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836624720 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1379836642231 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836642243 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379836644949 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836647069 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836648179 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836648500 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836649201 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836650730 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836652584 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836698658 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1379836700805 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1379836700808 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836704025 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1379836706493 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1379836707884 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836757460 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836760543 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836775677 -opened,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379836776137 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1379836776229 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1379836776235 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379836779132 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836787789 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379836796073 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836972695 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379836989893 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379836995026 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836998624 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836998657 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379836998667 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379836999126 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379837006987 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837008262 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379837021127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837029064 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1379837031841 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837031884 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837034003 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379837042461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837042738 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837044016 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837047186 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837067262 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837067268 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837083444 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837092591 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837116076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837129050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837156016 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837158281 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837161983 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837182053 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837182055 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837182067 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837182073 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837182076 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379837187995 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837188811 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837196190 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837198655 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837201557 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837222922 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379837223543 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837225964 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837235200 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837251630 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1379837274008 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379837274612 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837276944 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837282472 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837283643 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837290264 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837316307 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379837319424 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837320765 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379837321971 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837354040 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837380597 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837412283 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837438472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837458217 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837461998 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837465342 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837493534 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837524132 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379837524619 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837526827 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837526964 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837571356 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837581695 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837587656 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837590821 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837592660 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837592671 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379837598352 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837601211 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837601244 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1379837601255 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837610322 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837613871 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837618434 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638498 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638501 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837638513 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv deleted file mode 100644 index a19b3ad..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638516 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638518 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638521 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638523 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638527 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638529 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638540 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837638575 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837668471 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837670651 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837675157 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837679007 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837699070 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379837699508 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837701963 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837739966 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837762457 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837763052 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837763671 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837798730 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837802569 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837812116 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837815970 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837839231 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837839234 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379837839248 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837839250 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837855124 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837870557 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837882585 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837896195 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837906207 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379837916275 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837924612 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837944677 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379837945099 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379837947618 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379837988181 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379838008204 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838011200 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838013748 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838054176 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838054178 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379838054192 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838054193 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838060684 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838076444 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838078488 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838088379 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838119402 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838120724 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838122345 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838122956 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838223644 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838225761 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838227253 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838326929 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379838326944 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838327911 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838328572 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838331482 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838351545 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838351547 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379838351559 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838351560 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838351561 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838386464 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838390398 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838410460 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838410461 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379838410472 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838410474 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838410475 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838410477 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838422299 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838446553 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838447604 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838448199 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838449236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838449654 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838452199 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838468265 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838673918 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838691241 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838694182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838704573 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379838716872 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838719872 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838739929 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379838740349 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838742803 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838794884 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379838859891 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379838861179 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838885379 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838886007 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838887399 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838965594 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838988998 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379838997313 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839023316 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379839023880 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379839026443 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839029723 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839047648 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839049784 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839063147 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839064185 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839071648 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839075984 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839080739 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839131160 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839147277 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839170199 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839173419 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839186261 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379839199629 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379839207267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379839208249 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.smartEnter",1379839211469 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379839225378 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379839229056 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249119 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379839249130 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249133 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249134 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249135 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249136 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249136 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839249137 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379839276091 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379839278199 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839281212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839284344 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379839284355 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379839293101 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839313170 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839313171 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379839313184 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839313188 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839313189 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839454709 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839485850 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839495213 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839520938 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839521967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839711291 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379839714188 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839724873 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839735883 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379839738690 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840288890 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840291939 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840367667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840390689 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379840391319 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379840393729 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840395209 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840397500 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840429830 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840472033 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840974630 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840986247 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840986619 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840991308 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840998469 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379840999609 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841173236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841176459 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841277047 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841280887 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841283300 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841285808 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841307331 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841310063 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841372948 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841376445 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841389759 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841393241 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841395907 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841397192 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841402166 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841414272 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841423728 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841431622 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841433465 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841437904 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841450583 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841453949 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841456559 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841463614 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841466216 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841469132 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841470377 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841475854 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841486177 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841489215 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841491823 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841496792 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841497778 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379841505474 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841507912 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379841508046 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841521231 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379841524507 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842283631 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842287325 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842369229 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379842372335 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379842374917 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379842377624 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842381031 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842386392 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379842389119 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379842389479 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845389326 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845399327 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845703889 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1379845713627 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1379845716018 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845720806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845772126 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1379845772148 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379845781891 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379845792795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379845813390 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379845819023 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379846725283 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379846732790 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379846936092 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379846940302 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379847370155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379847375734 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379847402106 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379847407237 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379854344615 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379854350284 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379854357716 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379854367950 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379855197287 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379855201957 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856785166 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856791008 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856848817 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856849718 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856932841 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379856936555 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379857432628 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379857437581 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379857442052 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379857443885 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862143886 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862161345 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379862166751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379862169067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862171856 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379862188604 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862189448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379862192854 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379862196740 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379862198476 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862201862 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862294973 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862298575 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862305026 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862653511 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379862662947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379862664048 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862667373 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379862670347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379862672057 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862672876 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862673941 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862675369 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv deleted file mode 100644 index 299af17..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv +++ /dev/null @@ -1,168 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862827882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379862830609 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379862836175 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863051500 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379863054769 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863056632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863057924 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863058912 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863076890 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863081087 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863114432 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863116097 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863121721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379863122884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379863123599 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863127101 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863214176 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379863222574 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863230374 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863257144 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379863265440 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863268809 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863619398 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863627747 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863628291 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863629632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863633191 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863635738 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863684619 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863688429 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863688921 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379863690273 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864823338 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864845373 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864862950 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864865728 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864888087 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379864896437 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379865825624 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379865846148 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379865864950 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379865872392 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866302122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1379866320536 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379866323175 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1379866327251 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1379866327545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866328223 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866330673 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866334353 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866345689 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866351828 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866353517 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866354430 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866368527 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866372170 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866383049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866385778 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866387469 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866390253 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866393258 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866500134 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379866551705 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379866573537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379866575682 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866578772 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866582873 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1379866594315 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379866596797 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1379866603569 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379866605902 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866607370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866614204 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1379866622080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1379866622768 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1379866625825 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1379866626009 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866627979 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866628138 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866628290 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866628426 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1379866628562 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866631554 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866635129 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1379866642656 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379866648126 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379958353270 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379958354605 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1379958356175 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1379958356242 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1379958356399 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1379958356400 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1379958356400 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1379958357400 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1379958357401 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1379958357401 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1379958357401 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1379958357401 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1379958357401 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1379958357401 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1379958357401 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1379958357401 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1379958357401 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1379958357401 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1379958357401 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1379958357401 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1379958357402 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1379958357402 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1379958357402 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1379958357403 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1379958357403 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1379958357403 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1379958357403 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1379958357403 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1379958357403 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1379958357403 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1379958357403 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1379958357403 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1379958357403 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1379958357404 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1379958357404 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1379958357404 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1379958357404 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.13.0.132,"com.altera.sbtgui.flash.plugin",1379958357404 -stopped,bundle,com.altera.sbtgui.gprof,13.13.0.132,"com.altera.sbtgui.gprof",1379958357405 -stopped,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1379958357405 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1379958357407 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1379958357407 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1379958357407 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1379958357408 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1379958357408 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1379958357408 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1379958357408 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1379958357408 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1379958357408 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1379958357412 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1379958357412 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1379958357412 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1379958357412 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1379958357413 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1379958357413 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1379958357413 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1379958357413 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1379958357414 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1379958357414 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1379958357414 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1379958357414 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1379958357414 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1379958357417 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1379958357417 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1379958357417 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1379958357417 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1379958357418 -stopped,bundle,org.eclipse.rse.subsystems.files.ssh,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.ssh",1379958357418 -stopped,bundle,org.eclipse.rse.subsystems.shells.ssh,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.ssh",1379958357418 -stopped,bundle,org.eclipse.rse.subsystems.terminals.ssh,1.0.100.v201101042155,"org.eclipse.rse.subsystems.terminals.ssh",1379958357418 -stopped,bundle,org.eclipse.rse.connectorservice.ssh,2.1.200.v201101042155,"org.eclipse.rse.connectorservice.ssh",1379958357418 diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.history b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.history deleted file mode 100644 index 966ae72..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.history +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.index b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.index deleted file mode 100644 index 9a40f0e..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/9/39/refactorings.index +++ /dev/null @@ -1,3 +0,0 @@ -1379836543805 Delete resource 'exe/hello_world.c' -1379836549218 Delete resource 'exe/create-this-app' -1379836555206 Delete resource 'exe/readme.txt' diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index 27eb404..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 00987be..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml deleted file mode 100644 index 1dde63c..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index 7460fd1..0000000 --- a/syn/components/ps2/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/syn/components/ps2/software/.metadata/version.ini b/syn/components/ps2/software/.metadata/version.ini deleted file mode 100644 index c51ff74..0000000 --- a/syn/components/ps2/software/.metadata/version.ini +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/.lock b/syn/components/sd_card/software/.metadata/.lock deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/sd_card/software/.metadata/.log b/syn/components/sd_card/software/.metadata/.log deleted file mode 100644 index 3bc2b77..0000000 --- a/syn/components/sd_card/software/.metadata/.log +++ /dev/null @@ -1,97 +0,0 @@ -!SESSION 2013-08-18 12:31:35.377 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-08-18 12:31:36.162 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY org.eclipse.cdt.core 1 0 2013-08-18 12:32:34.104 -!MESSAGE Indexed 'exe_bsp' (77 sources, 55 headers) in 0.81 sec: 919 declarations; 2,181 references; 113 unresolved inclusions; 5 syntax errors; 193 unresolved names (5.86%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-08-18 12:32:35.464 -!MESSAGE Indexed 'exe' (1 sources, 13 headers) in 0.06 sec: 1 declarations; 1 references; 14 unresolved inclusions; 0 syntax errors; 0 unresolved names (0.00%) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 13:53:39.120 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 13:53:40.636 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 13:55:08.975 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 13:55:10.492 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:01:16.566 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:01:18.101 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:06:46.861 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:06:48.444 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:11:11.738 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:11:13.415 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:14:04.095 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:14:05.687 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:51:15.701 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:51:17.389 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:51:36.158 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:51:36.313 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:51:37.766 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:53:09.207 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:53:09.405 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:53:10.874 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:53:44.961 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-18 14:53:46.560 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/sd_card/software/exe/exe.elf] diff --git a/syn/components/sd_card/software/.metadata/.mylyn/repositories.xml.zip b/syn/components/sd_card/software/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index 0b589ae..0000000 Binary files a/syn/components/sd_card/software/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/.log b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/.log deleted file mode 100644 index 51012fd..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/.log +++ /dev/null @@ -1 +0,0 @@ -*** SESSION Aug 18, 2013 12:31:46.84 ------------------------------------------- diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376821955405.pdom b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376821955405.pdom deleted file mode 100644 index 2bbbdd6..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376821955405.pdom and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376821953233.pdom b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376821953233.pdom deleted file mode 100644 index 204cf81..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376821953233.pdom and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc deleted file mode 100644 index 53894eb..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc deleted file mode 100644 index 2bc2987..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml deleted file mode 100644 index d8d4735..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml +++ /dev/null @@ -1,8 +0,0 @@ - -
- -
-
-
-
-
diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log deleted file mode 100644 index 2e08ebf..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log +++ /dev/null @@ -1,10 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log deleted file mode 100644 index 6abdd49..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log +++ /dev/null @@ -1,180 +0,0 @@ - -**** Build of configuration Nios II for project exe_bsp **** - -make all -Compiling alt_alarm_start.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_alarm_start.o HAL/src/alt_alarm_start.c -Compiling alt_busy_sleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_busy_sleep.o HAL/src/alt_busy_sleep.c -Compiling alt_close.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_close.o HAL/src/alt_close.c -Compiling alt_dcache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush.o HAL/src/alt_dcache_flush.c -Compiling alt_dcache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_all.o HAL/src/alt_dcache_flush_all.c -Compiling alt_dcache_flush_no_writeback.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_no_writeback.o HAL/src/alt_dcache_flush_no_writeback.c -Compiling alt_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev.o HAL/src/alt_dev.c -Compiling alt_dev_llist_insert.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev_llist_insert.o HAL/src/alt_dev_llist_insert.c -Compiling alt_dma_rxchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_rxchan_open.o HAL/src/alt_dma_rxchan_open.c -Compiling alt_dma_txchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_txchan_open.o HAL/src/alt_dma_txchan_open.c -Compiling alt_do_ctors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_ctors.o HAL/src/alt_do_ctors.c -Compiling alt_do_dtors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_dtors.o HAL/src/alt_do_dtors.c -Compiling alt_env_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_env_lock.o HAL/src/alt_env_lock.c -Compiling alt_environ.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_environ.o HAL/src/alt_environ.c -Compiling alt_errno.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_errno.o HAL/src/alt_errno.c -Compiling alt_exception_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_entry.o HAL/src/alt_exception_entry.S -Compiling alt_exception_muldiv.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_muldiv.o HAL/src/alt_exception_muldiv.S -Compiling alt_exception_trap.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_trap.o HAL/src/alt_exception_trap.S -Compiling alt_execve.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_execve.o HAL/src/alt_execve.c -Compiling alt_exit.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_exit.o HAL/src/alt_exit.c -Compiling alt_fcntl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fcntl.o HAL/src/alt_fcntl.c -Compiling alt_fd_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_lock.o HAL/src/alt_fd_lock.c -Compiling alt_fd_unlock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_unlock.o HAL/src/alt_fd_unlock.c -Compiling alt_find_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_dev.o HAL/src/alt_find_dev.c -Compiling alt_find_file.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_file.o HAL/src/alt_find_file.c -Compiling alt_flash_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_flash_dev.o HAL/src/alt_flash_dev.c -Compiling alt_fork.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fork.o HAL/src/alt_fork.c -Compiling alt_fs_reg.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fs_reg.o HAL/src/alt_fs_reg.c -Compiling alt_fstat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fstat.o HAL/src/alt_fstat.c -Compiling alt_get_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_get_fd.o HAL/src/alt_get_fd.c -Compiling alt_getchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getchar.o HAL/src/alt_getchar.c -Compiling alt_getpid.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getpid.o HAL/src/alt_getpid.c -Compiling alt_gettod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gettod.o HAL/src/alt_gettod.c -Compiling alt_gmon.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gmon.o HAL/src/alt_gmon.c -Compiling alt_icache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush.o HAL/src/alt_icache_flush.c -Compiling alt_icache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush_all.o HAL/src/alt_icache_flush_all.c -Compiling alt_iic.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic.o HAL/src/alt_iic.c -Compiling alt_iic_isr_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic_isr_register.o HAL/src/alt_iic_isr_register.c -Compiling alt_instruction_exception_entry.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_entry.o HAL/src/alt_instruction_exception_entry.c -Compiling alt_instruction_exception_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_register.o HAL/src/alt_instruction_exception_register.c -Compiling alt_io_redirect.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_io_redirect.o HAL/src/alt_io_redirect.c -Compiling alt_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_ioctl.o HAL/src/alt_ioctl.c -Compiling alt_irq_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_irq_entry.o HAL/src/alt_irq_entry.S -Compiling alt_irq_handler.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_handler.o HAL/src/alt_irq_handler.c -Compiling alt_irq_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_register.o HAL/src/alt_irq_register.c -Compiling alt_irq_vars.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_vars.o HAL/src/alt_irq_vars.c -Compiling alt_isatty.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_isatty.o HAL/src/alt_isatty.c -Compiling alt_kill.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_kill.o HAL/src/alt_kill.c -Compiling alt_link.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_link.o HAL/src/alt_link.c -Compiling alt_load.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_load.o HAL/src/alt_load.c -Compiling alt_log_macro.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_log_macro.o HAL/src/alt_log_macro.S -Compiling alt_log_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_log_printf.o HAL/src/alt_log_printf.c -Compiling alt_lseek.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_lseek.o HAL/src/alt_lseek.c -Compiling alt_main.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_main.o HAL/src/alt_main.c -Compiling alt_malloc_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_malloc_lock.o HAL/src/alt_malloc_lock.c -Compiling alt_mcount.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_mcount.o HAL/src/alt_mcount.S -Compiling alt_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_open.o HAL/src/alt_open.c -Compiling alt_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_printf.o HAL/src/alt_printf.c -Compiling alt_putchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putchar.o HAL/src/alt_putchar.c -Compiling alt_putstr.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putstr.o HAL/src/alt_putstr.c -Compiling alt_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_read.o HAL/src/alt_read.c -Compiling alt_release_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_release_fd.o HAL/src/alt_release_fd.c -Compiling alt_remap_cached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_cached.o HAL/src/alt_remap_cached.c -Compiling alt_remap_uncached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_uncached.o HAL/src/alt_remap_uncached.c -Compiling alt_rename.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_rename.o HAL/src/alt_rename.c -Compiling alt_sbrk.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_sbrk.o HAL/src/alt_sbrk.c -Compiling alt_settod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_settod.o HAL/src/alt_settod.c -Compiling alt_software_exception.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_software_exception.o HAL/src/alt_software_exception.S -Compiling alt_stat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_stat.o HAL/src/alt_stat.c -Compiling alt_tick.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_tick.o HAL/src/alt_tick.c -Compiling alt_times.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_times.o HAL/src/alt_times.c -Compiling alt_uncached_free.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_free.o HAL/src/alt_uncached_free.c -Compiling alt_uncached_malloc.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_malloc.o HAL/src/alt_uncached_malloc.c -Compiling alt_unlink.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_unlink.o HAL/src/alt_unlink.c -Compiling alt_usleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_usleep.o HAL/src/alt_usleep.c -Compiling alt_wait.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_wait.o HAL/src/alt_wait.c -Compiling alt_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_write.o HAL/src/alt_write.c -Compiling altera_nios2_qsys_irq.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/altera_nios2_qsys_irq.o HAL/src/altera_nios2_qsys_irq.c -Compiling crt0.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/crt0.o HAL/src/crt0.S -Compiling alt_sys_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/alt_sys_init.o alt_sys_init.c -Compiling altera_avalon_jtag_uart_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_fd.o drivers/src/altera_avalon_jtag_uart_fd.c -Compiling altera_avalon_jtag_uart_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_init.o drivers/src/altera_avalon_jtag_uart_init.c -Compiling altera_avalon_jtag_uart_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o drivers/src/altera_avalon_jtag_uart_ioctl.c -Compiling altera_avalon_jtag_uart_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_read.o drivers/src/altera_avalon_jtag_uart_read.c -Compiling altera_avalon_jtag_uart_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_write.o drivers/src/altera_avalon_jtag_uart_write.c -Creating libhal_bsp.a... -rm -f -f libhal_bsp.a -nios2-elf-ar -src libhal_bsp.a obj/HAL/src/alt_alarm_start.o obj/HAL/src/alt_busy_sleep.o obj/HAL/src/alt_close.o obj/HAL/src/alt_dcache_flush.o obj/HAL/src/alt_dcache_flush_all.o obj/HAL/src/alt_dcache_flush_no_writeback.o obj/HAL/src/alt_dev.o obj/HAL/src/alt_dev_llist_insert.o obj/HAL/src/alt_dma_rxchan_open.o obj/HAL/src/alt_dma_txchan_open.o obj/HAL/src/alt_do_ctors.o obj/HAL/src/alt_do_dtors.o obj/HAL/src/alt_env_lock.o obj/HAL/src/alt_environ.o obj/HAL/src/alt_errno.o obj/HAL/src/alt_exception_entry.o obj/HAL/src/alt_exception_muldiv.o obj/HAL/src/alt_exception_trap.o obj/HAL/src/alt_execve.o obj/HAL/src/alt_exit.o obj/HAL/src/alt_fcntl.o obj/HAL/src/alt_fd_lock.o obj/HAL/src/alt_fd_unlock.o obj/HAL/src/alt_find_dev.o obj/HAL/src/alt_find_file.o obj/HAL/src/alt_flash_dev.o obj/HAL/src/alt_fork.o obj/HAL/src/alt_fs_reg.o obj/HAL/src/alt_fstat.o obj/HAL/src/alt_get_fd.o obj/HAL/src/alt_getchar.o obj/HAL/src/alt_getpid.o obj/HAL/src/alt_gettod.o obj/HAL/src/alt_gmon.o obj/HAL/src/alt_icache_flush.o obj/HAL/src/alt_icache_flush_all.o obj/HAL/src/alt_iic.o obj/HAL/src/alt_iic_isr_register.o obj/HAL/src/alt_instruction_exception_entry.o obj/HAL/src/alt_instruction_exception_register.o obj/HAL/src/alt_io_redirect.o obj/HAL/src/alt_ioctl.o obj/HAL/src/alt_irq_entry.o obj/HAL/src/alt_irq_handler.o obj/HAL/src/alt_irq_register.o obj/HAL/src/alt_irq_vars.o obj/HAL/src/alt_isatty.o obj/HAL/src/alt_kill.o obj/HAL/src/alt_link.o obj/HAL/src/alt_load.o obj/HAL/src/alt_log_macro.o obj/HAL/src/alt_log_printf.o obj/HAL/src/alt_lseek.o obj/HAL/src/alt_main.o obj/HAL/src/alt_malloc_lock.o obj/HAL/src/alt_mcount.o obj/HAL/src/alt_open.o obj/HAL/src/alt_printf.o obj/HAL/src/alt_putchar.o obj/HAL/src/alt_putstr.o obj/HAL/src/alt_read.o obj/HAL/src/alt_release_fd.o obj/HAL/src/alt_remap_cached.o obj/HAL/src/alt_remap_uncached.o obj/HAL/src/alt_rename.o obj/HAL/src/alt_sbrk.o obj/HAL/src/alt_settod.o obj/HAL/src/alt_software_exception.o obj/HAL/src/alt_stat.o obj/HAL/src/alt_tick.o obj/HAL/src/alt_times.o obj/HAL/src/alt_uncached_free.o obj/HAL/src/alt_uncached_malloc.o obj/HAL/src/alt_unlink.o obj/HAL/src/alt_usleep.o obj/HAL/src/alt_wait.o obj/HAL/src/alt_write.o obj/HAL/src/altera_nios2_qsys_irq.o obj/HAL/src/crt0.o obj/alt_sys_init.o obj/drivers/src/altera_avalon_jtag_uart_fd.o obj/drivers/src/altera_avalon_jtag_uart_init.o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o obj/drivers/src/altera_avalon_jtag_uart_read.o obj/drivers/src/altera_avalon_jtag_uart_write.o -[BSP build complete] - -**** Build Finished **** diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log deleted file mode 100644 index dcab2a1..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log +++ /dev/null @@ -1,181 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 9252 Bytes program size (code + initialized data). -Info: 22 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 10 KBytes program size (code + initialized data). -Info: 21 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -Info: Linking exe.elf -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -main.c:14: warning: implicit declaration of function 'memset' -Info: Linking exe.elf -main.c:14: warning: incompatible implicit declaration of built-in function 'memset' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:14: warning: passing argument 1 of 'memset' discards qualifiers from pointer target type -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -main.c:16: warning: passing argument 2 of '__builtin_stwio' makes integer from pointer without a cast -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -main.c:14: warning: implicit declaration of function 'memset' -Info: Linking exe.elf -main.c:14: warning: incompatible implicit declaration of built-in function 'memset' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:14: warning: passing argument 1 of 'memset' discards qualifiers from pointer target type -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -main.c:16: warning: passing argument 2 of '__builtin_stwio' makes integer from pointer without a cast -main.c:38: warning: passing argument 2 of '__builtin_stwio' makes integer from pointer without a cast -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c: In function 'main': -Info: Linking exe.elf -main.c:14: warning: implicit declaration of function 'memset' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:14: warning: incompatible implicit declaration of built-in function 'memset' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name soc --quartus_project_dir "/home/alek/aktualne/sd_card" --sopcinfo /home/alek/aktualne/sd_card/software/exe_bsp/../../soc.sopcinfo -main.c:14: warning: passing argument 1 of 'memset' discards qualifiers from pointer target type -main.c:16: warning: passing argument 2 of '__builtin_stwio' makes integer from pointer without a cast -main.c:40: warning: passing argument 2 of '__builtin_stwio' makes integer from pointer without a cast -Info: (exe.elf) 12 KBytes program size (code + initialized data). -Info: 19 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/505733d1fd0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/505733d1fd0700131d59ad360e988048 deleted file mode 100644 index f223382..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/18/505733d1fd0700131d59ad360e988048 +++ /dev/null @@ -1,15 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/b0e952bcf10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/b0e952bcf10700131d59ad360e988048 deleted file mode 100644 index 12734b1..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/23/b0e952bcf10700131d59ad360e988048 +++ /dev/null @@ -1,10 +0,0 @@ -/* - * main.c - * - * Created on: Aug 18, 2013 - * Author: alek - */ - - - - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/5a/505c226ffd0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/5a/505c226ffd0700131d59ad360e988048 deleted file mode 100644 index 29f13c4..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/5a/505c226ffd0700131d59ad360e988048 +++ /dev/null @@ -1,13 +0,0 @@ - -#include -#include -#include - -int main() { - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/61/80e49fb3f10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/61/80e49fb3f10700131d59ad360e988048 deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/6a/b02ee0adf10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/6a/b02ee0adf10700131d59ad360e988048 deleted file mode 100644 index a04d9c6..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/6a/b02ee0adf10700131d59ad360e988048 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * "Hello World" example. - * - * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on - * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example - * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT - * device in your system's hardware. - * The memory footprint of this hosted application is ~69 kbytes by default - * using the standard reference design. - * - * For a reduced footprint version of this template, and an explanation of how - * to reduce the memory footprint for a given application, see the - * "small_hello_world" template. - * - */ - -#include - -int main() -{ - printf("Hello from Nios II!\n"); - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/004d4a93fc0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/004d4a93fc0700131d59ad360e988048 deleted file mode 100644 index c1cf90a..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/79/004d4a93fc0700131d59ad360e988048 +++ /dev/null @@ -1,7 +0,0 @@ - -#include - -int main() { - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/20b481d3fd0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/20b481d3fd0700131d59ad360e988048 deleted file mode 100644 index 0065cf5..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/9b/20b481d3fd0700131d59ad360e988048 +++ /dev/null @@ -1,36 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - memset(buf, 0, sizeof(buf)); - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 2); //read - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for read: %d\n", status); - - if(status == 2) break; - } - - int i; - for(i=0; i<512; i++) { - if(i > 0 && (i%32) == 0) printf("\n"); - - printf("%02x ", buf[i]); - } - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/2046e919ff0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/2046e919ff0700131d59ad360e988048 deleted file mode 100644 index 2ab2af0..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a/2046e919ff0700131d59ad360e988048 +++ /dev/null @@ -1,37 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - memset(buf, 0, sizeof(buf)); - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 2); //read - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for read: %d\n", status); - - if(status == 2) break; - } - - int i; - for(i=0; i<512; i++) { - if(i > 0 && (i%32) == 0) printf("\n"); - - printf("%02x ", buf[i]); - } - printf("\n"); - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f0183b34ff0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f0183b34ff0700131d59ad360e988048 deleted file mode 100644 index 7ac7bd2..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f0183b34ff0700131d59ad360e988048 +++ /dev/null @@ -1,46 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - memset(buf, 0, sizeof(buf)); - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 2); //read - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for read: %d\n", status); - - if(status == 2) break; - } - - int i; - for(i=0; i<512; i++) { - if(i > 0 && (i%32) == 0) printf("\n"); - - printf("%02x ", buf[i]); - } - printf("\n"); - - for(i=0; i<512; i++) buf[i] = i; - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 3); //write - - - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/aa/d08e00bdf10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/aa/d08e00bdf10700131d59ad360e988048 deleted file mode 100644 index e31ce27..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/aa/d08e00bdf10700131d59ad360e988048 +++ /dev/null @@ -1,7 +0,0 @@ - -#include - -int main() { - - return 0l -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b42e2cff0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b42e2cff0700131d59ad360e988048 deleted file mode 100644 index 1cf328b..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b42e2cff0700131d59ad360e988048 +++ /dev/null @@ -1,42 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - memset(buf, 0, sizeof(buf)); - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 2); //read - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for read: %d\n", status); - - if(status == 2) break; - } - - int i; - for(i=0; i<512; i++) { - if(i > 0 && (i%32) == 0) printf("\n"); - - printf("%02x ", buf[i]); - } - printf("\n"); - - for(i=0; i<512; i++) buf[i] = i; - - - - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b4/60bcc9dffc0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b4/60bcc9dffc0700131d59ad360e988048 deleted file mode 100644 index 52cb72f..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/b4/60bcc9dffc0700131d59ad360e988048 +++ /dev/null @@ -1,9 +0,0 @@ - -#include - -int main() { - - printf("Hallo \n"); - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/be/a0d00fabf10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/be/a0d00fabf10700131d59ad360e988048 deleted file mode 100644 index 7d0742f..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/be/a0d00fabf10700131d59ad360e988048 +++ /dev/null @@ -1,26 +0,0 @@ -Readme - Hello World Software Example - -DESCRIPTION: -Simple program that prints "Hello from Nios II" - -The memory footprint of this hosted application is intended to be small (under 100 kbytes) by default -using a standard reference deisgn. - -For an even smaller, reduced footprint version of this template, and an explanation of how -to reduce the memory footprint for a given application, see the -"small_hello_world" template. - - -PERIPHERALS USED: -This example exercises the following peripherals: -- STDOUT device (UART or JTAG UART) - -SOFTWARE SOURCE FILES: -This example includes the following software source files: -- hello_world.c: Everyone needs a Hello World program, right? - -BOARD/HOST REQUIREMENTS: -This example requires only a JTAG connection with a Nios Development board. If -the host communication settings are changed from JTAG UART (default) to use a -conventional UART, a serial cable between board DB-9 connector and the host is -required. diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d03d79b2fc0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d03d79b2fc0700131d59ad360e988048 deleted file mode 100644 index 8a211bc..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d03d79b2fc0700131d59ad360e988048 +++ /dev/null @@ -1,9 +0,0 @@ - -#include - -int main() { - - - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/d7/203eaca8f10700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/d7/203eaca8f10700131d59ad360e988048 deleted file mode 100755 index 9311c92..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/d7/203eaca8f10700131d59ad360e988048 +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# This script creates the hello_world application in this directory. - - -BSP_DIR=../exe_bsp -QUARTUS_PROJECT_DIR=../../ -NIOS2_APP_GEN_ARGS="--elf-name exe.elf --set OBJDUMP_INCLUDE_SOURCE 1 --src-files hello_world.c" - - -# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set. -# This variable is required for the command line tools to execute correctly. -if [ -z "${SOPC_KIT_NIOS2}" ] -then - echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set! - exit 1 -fi - - -# Also make sure that the APP has not been created already. Check for -# existence of Makefile in the app directory -if [ -f ./Makefile ] -then - echo Application has already been created! Delete Makefile if you want to create a new application makefile - exit 1 -fi - - -# We are selecting hal_default bsp because it supports this application. -# Check to see if the hal_default has already been generated by checking for -# existence of the public.mk file. If not, we need to run -# create-this-bsp file to generate the bsp. -if [ ! -f ${BSP_DIR}/public.mk ]; then - # Since BSP doesn't exist, create the BSP - # Pass any command line arguments passed to this script to the BSP. - pushd ${BSP_DIR} >> /dev/null - ./create-this-bsp "$@" || { - echo "create-this-bsp failed" - exit 1 - } - popd >> /dev/null -fi - - -# Don't run make if create-this-app script is called with --no-make arg -SKIP_MAKE= -while [ $# -gt 0 ] -do - case "$1" in - --no-make) - SKIP_MAKE=1 - ;; - esac - shift -done - - -# Now we also need to go copy the sources for this application to the -# local directory. -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || { - echo "failed during copying example source files" - exit 1 -} - -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || { - echo "failed copying readme file" -} - -if [ -d "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" ] -then - cp -RL "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" . || { - echo "failed during copying project support files" - exit 1 - } -fi - -chmod -R +w . || { - echo "failed during changing file permissions" - exit 1 -} - -cmd="nios2-app-generate-makefile --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}" - -echo "create-this-app: Running \"${cmd}\"" -$cmd || { - echo "nios2-app-generate-makefile failed" - exit 1 -} - -if [ -z "$SKIP_MAKE" ]; then - cmd="make" - - echo "create-this-app: Running \"$cmd\"" - $cmd || { - echo "make failed" - exit 1 - } - - echo - echo "To download and run the application:" - echo " 1. Make sure the board is connected to the system." - echo " 2. Run 'nios2-configure-sof ' to configure the FPGA with the hardware design." - echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell." - echo " 4. Run 'make download-elf' from the application directory." - echo - echo "To debug the application:" - echo " Import the project into Nios II Software Build Tools for Eclipse." - echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information." - echo - echo -e "" -fi - - -exit 0 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/eb/606ce1f9fc0700131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/eb/606ce1f9fc0700131d59ad360e988048 deleted file mode 100644 index 9a50df2..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/eb/606ce1f9fc0700131d59ad360e988048 +++ /dev/null @@ -1,13 +0,0 @@ - -#include -#include -#include - -int main() { - - printf("Hallo \n"); - - - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/f3/f0c47d1c050800131d59ad360e988048 b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/f3/f0c47d1c050800131d59ad360e988048 deleted file mode 100644 index 8451a57..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.history/f3/f0c47d1c050800131d59ad360e988048 +++ /dev/null @@ -1,52 +0,0 @@ - -#include -#include -#include - -int main() { - - volatile unsigned char buf[512]; - - int status = IORD(SD_CARD_0_BASE, 0); - - printf("SD card status: %d\n", status); - - memset(buf, 0, sizeof(buf)); - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 2); //read - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for read: %d\n", status); - - if(status == 2) break; - } - - int i; - for(i=0; i<512; i++) { - if(i > 0 && (i%32) == 0) printf("\n"); - - printf("%02x ", buf[i]); - } - printf("\n"); - - for(i=0; i<512; i++) buf[i] = i; - - IOWR(SD_CARD_0_BASE, 0, buf); - IOWR(SD_CARD_0_BASE, 1, 0); - IOWR(SD_CARD_0_BASE, 2, 1); - IOWR(SD_CARD_0_BASE, 3, 3); //write - - while(1) { - status = IORD(SD_CARD_0_BASE, 0); - printf("SD card status for write: %d\n", status); - - if(status == 2) break; - } - - - return 0; -} diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index deleted file mode 100644 index a9a478f..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index deleted file mode 100644 index 623fa34..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index deleted file mode 100644 index 2b3da83..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index e2c27d6..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version deleted file mode 100644 index 6b2aaa7..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree deleted file mode 100644 index 05a8644..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources deleted file mode 100644 index 2991945..0000000 Binary files a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and /dev/null differ diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs deleted file mode 100644 index 30d6a52..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -newSoftwareExampleWizardPage.defaultLocation=/home/alek/aktualne/sd_card/software/exe -newSoftwareExampleWizardPage.sopcinfoFile=/home/alek/aktualne/sd_card/soc.sopcinfo -newSoftwareExampleWizardPage2.newBspLocation=/home/alek/aktualne/sd_card/software/exe_bsp diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs deleted file mode 100644 index b8c9267..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.debug.core.cDebug.default_source_containers=\n\n\n\n\n\n\n\n diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index 1cd90b6..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -properties/exe.null.1202401963/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1395749100=\#\n\#Sun Aug 18 14\:53\:44 CEST 2013\norg.eclipse.cdt.build.core.settings.holder.1960793843\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:38 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.564816553\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:38 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.999012719\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:38 CEST 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.1671501914\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.libs.1984774648\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:38 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.1625936266\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.953467042\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:38 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.archiver.base.165071489\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1395749100\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:44 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.2068180747\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.assembler.base.89195491\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.103778270\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.1527153124\=\\\#\\n\\\#Sun Aug 18 14\\\:53\\\:44 CEST 2013\\nrebuildState\\\=false\\n\n -properties/exe_bsp.null.941998373/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1846274097=\#\n\#Sun Aug 18 13\:51\:49 CEST 2013\ncdt.managedbuild.tool.gnu.cpp.linker.base.1449892077\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.libs.936179280\=\\\#\\n\\\#Sun Aug 18 12\\\:32\\\:35 CEST 2013\\nrebuildState\\\=true\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1846274097\=\\\#\\n\\\#Sun Aug 18 12\\\:34\\\:43 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.1743612784\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1279687957\=\\\#\\n\\\#Sun Aug 18 12\\\:32\\\:35 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.c.linker.base.270671047\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.assembler.base.1567518899\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.archiver.base.1833210667\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1715053658\=\\\#\\n\\\#Sun Aug 18 12\\\:32\\\:35 CEST 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.2062081683\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.602965739\=\\\#\\n\\\#Sun Aug 18 12\\\:32\\\:35 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.639661987\=\\\#\\n\\\#Sun Aug 18 12\\\:32\\\:35 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.1750479667\=\\\#\\n\\\#Sun Aug 18 13\\\:51\\\:49 CEST 2013\\nrebuildState\\\=false\\n\n diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs deleted file mode 100644 index 0451f54..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.cdt.ui.run.count.3_3_0=1 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs deleted file mode 100644 index cbfe61a..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs +++ /dev/null @@ -1,5 +0,0 @@ -content_assist_disabled_computers=org.eclipse.cdt.ui.parserProposalCategory\u0000org.eclipse.cdt.ui.textProposalCategory\u0000 -eclipse.preferences.version=1 -spelling_locale_initialized=true -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index a7fb09f..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -description.autobuilding=false -eclipse.preferences.version=1 -version=1 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs deleted file mode 100644 index 57e3b77..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug;org.eclipse.cdt.cdi.launch.localCLaunch,run -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.remoteApplicationLaunchType=org.eclipse.rse.remotecdt.dsf.debug,debug -eclipse.preferences.version=1 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs deleted file mode 100644 index a2917e5..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n -preferredTargets=org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget| diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs deleted file mode 100644 index 89810d2..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.epp.usagedata.recording.last-upload=1376821910161 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs deleted file mode 100644 index 43e97e4..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -mylyn.attention.migrated=true diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs deleted file mode 100644 index 8d462a6..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs deleted file mode 100644 index f9e585b..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -pref_first_startup=false diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs deleted file mode 100644 index 56cd496..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.team.ui.first_time=false diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs deleted file mode 100644 index 61f3bb8..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -overviewRuler_migration=migrated_3.1 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index a9b1d08..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,5 +0,0 @@ -PROBLEMS_FILTERS_MIGRATE=true -eclipse.preferences.version=1 -platformState=1376506471813 -quickStart=false -tipsAndTricks=true diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index 08076f2..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -showIntro=false diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs deleted file mode 100644 index 68b875a..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ /dev/null @@ -1,2 +0,0 @@ -ENABLED_DECORATORS=com.altera.sbtgui.project.decorator.bsp\:true,com.altera.sbtgui.project.nios2builddecorator\:true,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false, -eclipse.preferences.version=1 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch deleted file mode 100644 index 624cc61..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml deleted file mode 100644 index bedcf0e..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- - - - - - -
-
diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 795c14e..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv deleted file mode 100644 index 4dbaa6b..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1376821909066 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1376821909067 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1376821909067 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376821909068 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1376821909068 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376821909069 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376821909069 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376821909070 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376821909070 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376821909071 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376821909072 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376821909073 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1376821909074 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1376821909074 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1376821909075 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1376821909075 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1376821909076 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1376821909076 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1376821909076 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1376821909077 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1376821909077 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1376821909078 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1376821909078 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1376821909079 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376821909080 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376821909082 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1376821909082 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1376821909083 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1376821909083 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1376821909083 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1376821909084 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1376821909084 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1376821909084 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1376821909085 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1376821909085 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1376821909086 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1376821909086 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1376821909087 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1376821909087 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1376821909087 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1376821909088 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376821909088 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1376821909089 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376821909089 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1376821909090 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1376821909090 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1376821909090 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1376821909091 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376821909091 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1376821909092 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376821909092 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376821909093 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376821909093 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1376821909094 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1376821909094 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376821909095 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376821909096 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1376821909097 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1376821909097 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1376821909098 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1376821909098 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1376821909099 -started,bundle,org.eclipse.ui.intro,3.4.100.v20110425,"org.eclipse.ui.intro",1376821909100 -started,bundle,org.eclipse.ui.intro.universal,3.2.500.v20110510,"org.eclipse.ui.intro.universal",1376821909100 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1376821909100 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376821909100 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1376821909101 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1376821909101 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1376821909102 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1376821909102 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1376821909103 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1376821909103 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1376821909103 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1376821909104 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376821909105 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376821909105 -started,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376821909106 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1376821909106 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1376821909106 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1376821909107 -os,sysinfo,,,"linux",1376821909109 -arch,sysinfo,,,"x86",1376821909109 -ws,sysinfo,,,"gtk",1376821909109 -locale,sysinfo,,,"en_US",1376821909109 -processors,sysinfo,,,"8",1376821909109 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1376821909109 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1376821909109 -java.specification.name,sysinfo,,,"Java Platform API Specification",1376821909109 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376821909109 -java.specification.version,sysinfo,,,"1.6",1376821909109 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1376821909109 -java.version,sysinfo,,,"1.6.0_23",1376821909109 -java.vm.info,sysinfo,,,"mixed mode",1376821909109 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1376821909109 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1376821909109 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376821909109 -java.vm.specification.version,sysinfo,,,"1.0",1376821909109 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1376821909109 -java.vm.version,sysinfo,,,"19.0-b09",1376821909109 -activated,view,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.internal.introview",1376821910032 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376821910036 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376821913164 -opened,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376821917035 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376821917127 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376821917130 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376821917130 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376821917131 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376821917284 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376821953053 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1376821953085 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376821954536 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376821957281 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1376821959104 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376821959107 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376821962254 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376821992099 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376821995374 -started,bundle,org.eclipse.core.databinding,1.4.0.I20110111-0800,"org.eclipse.core.databinding",1376821997739 -started,bundle,org.eclipse.core.databinding.property,1.4.0.I20110222-0800,"org.eclipse.core.databinding.property",1376821997748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1376822018685 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822018698 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822018993 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822019066 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822023825 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376822025003 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376822025003 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822025011 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822027727 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376822028999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376822028999 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822029007 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822031828 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376822034258 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376822034258 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822034267 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822034310 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822034982 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822039587 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822043658 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822043956 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376822044324 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376822044392 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822044443 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822044499 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822044663 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376822044784 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376822046927 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376822057937 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376822059073 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376822060977 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822062258 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376822064593 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1376822069212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822069221 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376822071050 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822074750 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822079246 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822081472 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822081664 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822083495 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822084174 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822084477 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822085089 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376822089041 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826683727 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826690485 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826693008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826699976 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826704695 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826707147 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826707431 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826709054 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826709985 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826710062 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826710771 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826711050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376826713555 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376826714361 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376826714363 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826718461 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826723039 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826724285 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826759907 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376826765874 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826768669 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376826771190 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376826772536 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826818385 -opened,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376826819053 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376826819153 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376826819159 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376826822054 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826828169 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376826841897 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376826852009 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826856170 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826856205 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376826856215 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826856730 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376826863643 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376826866868 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376826868349 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376826875897 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376826876124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376826876603 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376826885675 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376826888921 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376826909005 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826909028 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826909030 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826909034 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826909036 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376826911918 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376826919510 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827064328 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376827069121 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827082393 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376827102656 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376827104869 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827109078 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827113533 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827153140 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827153800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827154724 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827156042 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376827166760 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376827168461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827246921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827250790 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376827256505 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376827256521 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376827277004 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376827279532 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827295212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827296084 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827297952 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827299242 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827351767 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827572961 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827576669 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827581055 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827606882 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827606886 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376827607510 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376827609871 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827704041 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827762832 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376827764233 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827798407 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827799859 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827808623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376827811924 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376827815155 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376827818213 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827829061 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376827833732 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376827836222 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376827838809 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376827840950 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376827841109 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376827841261 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376827841397 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376827842564 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827844980 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827847165 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376827851670 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827871763 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376827872341 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376827874851 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827877691 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827893407 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827899761 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376827910655 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376828008498 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376828012170 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv deleted file mode 100644 index f067d36..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv +++ /dev/null @@ -1,71 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376828021407 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376828044693 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376828047125 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830021099 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830259656 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830261602 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830265757 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376830276303 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376830278821 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376830296752 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376830299201 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830315271 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830328924 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376830328953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376830379715 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376830389231 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376830389846 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376830392313 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830409955 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830410894 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830411194 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376830419399 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376830425558 -activated,view,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch.hardware.ByteStreamConsoleView",1376830427995 -no handler,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376830436233 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376834100961 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376946982585 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376946984310 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376946985662 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376946985721 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1376946985940 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376946985941 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376946985941 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376946985941 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376946985941 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376946985941 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376946985941 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376946985941 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376946985941 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1376946985941 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376946985941 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376946985941 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1376946985942 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1376946985942 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376946985942 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1376946985943 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1376946985943 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376946985943 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376946985943 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376946985943 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1376946985944 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376946985944 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376946985944 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1376946985945 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376946985945 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1376946985951 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376946985951 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1376946985953 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376946985953 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376946985953 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376946985953 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376946985953 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376946985953 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.13.0.132,"com.altera.sbtgui.flash.plugin",1376946985954 -stopped,bundle,com.altera.sbtgui.gprof,13.13.0.132,"com.altera.sbtgui.gprof",1376946985955 -stopped,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376946985955 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376946985955 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376946985955 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376946985955 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376946985955 diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.history b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.history deleted file mode 100644 index fe0c971..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.history +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.index b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.index deleted file mode 100644 index 9a51daf..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/34/refactorings.index +++ /dev/null @@ -1,3 +0,0 @@ -1376822024973 Delete resource 'exe/create-this-app' -1376822028972 Delete resource 'exe/readme.txt' -1376822033695 Delete resource 'exe/hello_world.c' diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index 27eb404..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 5ca0b77..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml deleted file mode 100644 index 560fb08..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index 4f2cdbb..0000000 --- a/syn/components/sd_card/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/syn/components/sd_card/software/.metadata/version.ini b/syn/components/sd_card/software/.metadata/version.ini deleted file mode 100644 index c51ff74..0000000 --- a/syn/components/sd_card/software/.metadata/version.ini +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/.lock b/syn/components/vga/software/.metadata/.lock deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/vga/software/.metadata/.log b/syn/components/vga/software/.metadata/.log deleted file mode 100644 index da1e0fe..0000000 --- a/syn/components/vga/software/.metadata/.log +++ /dev/null @@ -1,1845 +0,0 @@ -!SESSION 2013-08-10 12:36:57.802 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-08-10 12:36:58.997 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY org.eclipse.cdt.core 1 0 2013-08-10 12:38:02.169 -!MESSAGE Indexed 'exe_bsp' (77 sources, 55 headers) in 1.09 sec: 919 declarations; 2,181 references; 113 unresolved inclusions; 5 syntax errors; 193 unresolved names (5.86%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-08-10 12:38:04.039 -!MESSAGE Indexed 'exe' (1 sources, 13 headers) in 0.05 sec: 1 declarations; 1 references; 14 unresolved inclusions; 0 syntax errors; 0 unresolved names (0.00%) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:42:48.716 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:42:49.930 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:17.833 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:17.858 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:19.089 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:44.895 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:44.918 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:43:46.145 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:47:12.138 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:47:12.173 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:47:13.419 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:49:48.961 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:49:48.980 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:49:50.188 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:51:59.804 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:51:59.824 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:01.034 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:12.791 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:12.818 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:14.043 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:27.107 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:27.133 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:28.368 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:51.155 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:51.184 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:52:52.425 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:11.356 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:11.377 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:12.606 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:31.934 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:31.962 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:33.201 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:42.033 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:42.053 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:43.265 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:50.721 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:50.739 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:53:51.948 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:01.932 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:01.952 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:03.168 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:12.048 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:12.077 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 12:54:13.316 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:25.432 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:25.455 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:26.681 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:52.458 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:52.481 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:02:53.709 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:29:05.827 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:29:05.858 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:29:07.090 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:25.311 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:25.341 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:26.578 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:46.806 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:46.837 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:34:48.062 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:35:00.512 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:35:00.534 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:35:01.749 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:37:05.337 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:37:05.358 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:37:06.576 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:38:56.531 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:38:56.564 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:38:57.803 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:41:26.272 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:41:26.292 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:41:27.502 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:42:45.890 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:42:45.917 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 13:42:47.153 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:15:42.907 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:15:42.935 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:15:44.170 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:14.573 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:14.598 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:15.832 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:43.713 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:43.742 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 14:16:44.967 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:20:59.041 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:20:59.064 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:21:00.288 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:23:32.001 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:23:32.025 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:23:33.251 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:26:16.094 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:26:16.122 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:26:17.356 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:43:58.045 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:43:58.068 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:43:59.304 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:48:43.512 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:48:43.540 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:48:44.763 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:19.701 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:19.720 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:20.932 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:29.640 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:29.666 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 15:49:30.899 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 17:39:19.149 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [1-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 17:39:19.178 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --stop] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-10 17:39:20.395 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [1-1.6]' --device=1 --instance=0 --go /home/alek/aktualne/vga/software/exe/exe.elf] -!SESSION 2013-08-14 20:54:30.770 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-08-14 20:54:33.102 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 20:56:25.314 -!MESSAGE Unable to validate connection settings. -!STACK 0 -java.lang.Exception: Connected system ID hash not found on target at expected base address. - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.assertTrue(SystemConsoleConnectionModel.java:645) - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateSystemId(SystemConsoleConnectionModel.java:589) - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateConnectionSettings(SystemConsoleConnectionModel.java:511) - at com.altera.sbtgui.launch.hardware.AbstractNios2CLaunchDelegate.launch(AbstractNios2CLaunchDelegate.java:115) - at com.altera.sbtgui.launch.hardware.Nios2HardwareLaunchDelegate.launch(Nios2HardwareLaunchDelegate.java:98) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703) - at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937) - at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 20:56:25.319 -!MESSAGE Unable to validate connection settings. -!STACK 0 -java.lang.Exception: Connected system ID hash not found on target at expected base address. - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.assertTrue(SystemConsoleConnectionModel.java:645) - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateSystemId(SystemConsoleConnectionModel.java:589) - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateConnectionSettings(SystemConsoleConnectionModel.java:511) - at com.altera.sbtgui.launch.hardware.AbstractNios2CLaunchDelegate.launch(AbstractNios2CLaunchDelegate.java:115) - at com.altera.sbtgui.launch.hardware.Nios2HardwareLaunchDelegate.launch(Nios2HardwareLaunchDelegate.java:98) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703) - at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937) - at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:57:05.669 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 20:57:06.752 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:57:06.755 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:13.296 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:13.313 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 20:58:14.363 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:14.366 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:23.343 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:23.359 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 20:58:24.413 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 20:58:24.416 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:07:25.799 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:07:25.815 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:07:26.867 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:07:26.868 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:08:12.428 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:08:12.446 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:08:13.497 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:08:13.500 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:06.740 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:06.757 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:09:07.808 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:07.810 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:53.343 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:53.359 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:09:54.410 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:09:54.412 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:06.646 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:06.662 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:10:07.712 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:07.714 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:17.033 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:17.050 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:10:18.101 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:18.104 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:48.486 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:48.502 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:10:49.555 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:10:49.558 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:03.339 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:03.356 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:12:04.407 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:04.427 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:27.635 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:27.653 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:12:28.703 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:28.705 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:55.186 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:55.206 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:12:56.264 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:12:56.265 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:16.870 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:16.887 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:14:17.941 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:17.943 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:29.838 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:29.854 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:14:30.909 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:14:30.911 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:15:41.705 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:15:41.720 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:15:42.772 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:15:42.775 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:01.528 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:01.544 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:16:02.598 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:02.600 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:42.533 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:42.553 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:16:43.605 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:43.608 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:57.794 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:57.810 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:16:58.862 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:16:58.864 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:17:13.245 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:17:13.261 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:17:14.315 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:17:14.317 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:18:27.199 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:18:27.215 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:18:28.272 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:18:28.293 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:20:06.292 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:20:06.310 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:20:07.363 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:20:07.365 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:21:22.570 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:21:22.587 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:21:23.637 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:21:23.640 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:22:43.891 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:22:43.914 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:22:44.969 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:22:44.971 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:23:01.658 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:23:01.673 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-14 21:23:02.725 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-14 21:23:02.727 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY org.eclipse.ui 4 0 2013-08-15 14:48:04.486 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2013-08-16 01:11:31.176 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-08-16 01:11:32.142 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 01:13:45.000 -!MESSAGE Unable to validate connection settings. -!STACK 0 -java.lang.Exception - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateConnectionSettings(SystemConsoleConnectionModel.java:555) - at com.altera.sbtgui.launch.hardware.AbstractNios2CLaunchDelegate.launch(AbstractNios2CLaunchDelegate.java:115) - at com.altera.sbtgui.launch.hardware.Nios2HardwareLaunchDelegate.launch(Nios2HardwareLaunchDelegate.java:98) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703) - at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937) - at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 01:13:45.006 -!MESSAGE Unable to validate connection settings. -!STACK 0 -java.lang.Exception - at com.altera.embeddedsw.flash.model.internal.SystemConsoleConnectionModel.validateConnectionSettings(SystemConsoleConnectionModel.java:555) - at com.altera.sbtgui.launch.hardware.AbstractNios2CLaunchDelegate.launch(AbstractNios2CLaunchDelegate.java:115) - at com.altera.sbtgui.launch.hardware.Nios2HardwareLaunchDelegate.launch(Nios2HardwareLaunchDelegate.java:98) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854) - at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703) - at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937) - at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 01:14:57.645 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 01:14:58.714 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 01:14:58.718 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 01:17:27.083 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 01:17:27.100 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 01:17:28.147 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 01:17:28.149 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:01:53.496 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:01:53.512 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:01:54.564 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:01:54.569 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:03:07.165 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:03:07.182 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:03:08.231 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:03:08.233 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:10.955 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:10.970 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:05:12.021 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:12.024 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:34.347 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:34.363 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:05:35.413 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:05:35.415 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:30.082 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:30.098 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:06:31.146 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:31.148 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:55.920 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:55.936 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:06:56.991 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:06:56.994 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:07:46.451 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:07:46.466 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:07:47.514 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:07:47.516 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:15.665 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:15.681 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:08:16.734 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:16.736 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:57.130 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:57.145 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:08:58.196 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:08:58.199 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:09:40.941 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:09:40.957 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:09:42.005 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:09:42.008 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:10:30.962 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:10:30.979 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 02:10:32.027 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 02:10:32.029 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:33:23.278 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:33:23.296 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 08:33:24.351 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:33:24.355 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:49:57.079 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:49:57.096 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 08:49:58.150 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:49:58.152 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:50:57.106 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:50:57.124 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 08:50:58.174 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 08:50:58.176 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 09:20:44.705 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 09:20:44.727 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 09:20:45.779 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 09:20:45.781 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:50:49.252 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:50:49.268 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 10:50:50.320 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:50:50.322 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:33.943 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:33.960 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 10:51:35.013 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:35.015 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:48.753 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:48.770 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 10:51:49.830 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 10:51:49.832 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:03:43.693 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:03:43.709 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:03:44.762 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:03:44.764 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:04:35.216 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:04:35.235 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:04:36.290 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:04:36.292 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:11:20.394 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:11:20.410 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:11:21.471 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:11:21.473 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:15:46.685 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:15:46.703 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:15:47.754 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:15:47.757 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:17:47.728 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:17:47.744 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:17:48.795 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:17:48.797 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:19:16.975 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:19:16.992 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:19:18.044 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:19:18.047 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:20:50.797 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:20:50.814 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:20:51.868 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:20:51.870 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:43:25.783 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:43:25.800 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:43:26.851 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:43:26.853 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:48:50.143 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:48:50.160 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:48:51.211 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:48:51.214 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:54:22.033 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:54:22.051 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:54:23.101 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:54:23.104 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:57:46.988 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:57:47.006 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:57:48.058 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:57:48.061 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:58:33.852 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:58:33.869 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 12:58:34.919 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 12:58:34.921 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:00:44.338 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:00:44.355 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:00:45.407 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:00:45.409 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:03:10.475 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:03:10.491 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:03:11.543 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:03:11.545 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:04:59.554 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:04:59.570 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:05:00.620 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:05:00.623 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:07:38.062 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:07:38.078 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:07:39.131 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:07:39.133 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:09:01.668 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:09:01.685 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:09:02.739 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:09:02.741 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:11:10.335 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:11:10.355 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:11:11.405 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:11:11.408 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:18:25.263 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:18:25.280 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:18:26.334 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:18:26.337 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:20:27.243 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:20:27.260 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:20:28.314 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:20:28.316 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:45:59.377 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:45:59.394 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:46:00.448 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:46:00.450 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:58:03.551 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:58:03.566 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:58:04.617 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:58:04.620 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:59:45.563 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:59:45.580 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 13:59:46.629 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 13:59:46.631 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:00:18.084 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:00:18.101 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:00:19.155 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:00:19.157 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:01:02.283 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:01:02.300 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:01:03.351 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:01:03.353 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:01.082 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:01.098 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:22:02.150 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:02.151 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:35.595 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:35.611 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:22:36.662 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:22:36.664 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:17.818 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:17.836 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:23:18.887 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:18.889 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:38.731 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:38.750 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:23:39.804 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:23:39.807 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:24:41.955 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:24:41.971 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:24:43.026 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:24:43.028 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:44:37.313 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:44:37.329 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:44:38.380 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:44:38.382 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:45:10.012 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:45:10.030 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:45:11.082 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:45:11.084 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:46:33.516 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:46:33.534 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:46:34.586 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:46:34.588 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:47:42.298 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:47:42.315 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:47:43.367 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:47:43.369 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:58:34.245 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:58:34.261 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 14:58:35.315 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 14:58:35.317 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:00:40.611 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:00:40.627 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:00:41.678 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:00:41.681 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:02:29.634 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:02:29.650 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:02:30.703 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:02:30.704 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:13.919 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:13.937 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:06:14.988 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:14.991 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:47.455 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:47.470 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:06:48.524 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:06:48.526 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:05.899 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:05.918 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:08:06.970 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:06.972 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:22.206 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:22.222 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:08:23.279 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:08:23.281 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:11:21.188 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:11:21.206 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:11:22.263 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:11:22.265 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:17:03.156 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:17:03.174 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:17:04.230 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:17:04.232 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:18:01.130 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:18:01.146 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:18:02.201 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:18:02.203 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:19:57.963 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:19:57.977 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:19:59.029 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:19:59.032 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:20:34.876 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:20:34.891 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:20:35.946 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:20:35.948 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:21:38.663 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:21:38.680 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:21:39.735 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:21:39.738 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:24:23.249 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:24:23.264 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:24:24.317 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:24:24.320 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:25:44.857 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:25:44.873 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:25:45.928 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:25:45.931 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:26:05.981 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:26:05.996 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:26:07.048 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:26:07.050 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:35:46.951 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:35:46.966 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:35:48.017 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:35:48.019 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:37:17.257 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:37:17.274 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:37:18.326 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:37:18.328 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:38:37.778 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:38:37.794 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:38:38.847 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:38:38.849 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:39:21.456 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:39:21.473 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:39:22.524 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:39:22.526 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:42:31.440 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:42:31.456 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:42:32.510 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:42:32.513 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:43:53.294 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:43:53.311 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:43:54.365 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:43:54.367 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:50:15.195 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:50:15.212 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:50:16.263 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:50:16.266 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:16.844 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:16.859 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:51:17.910 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:17.912 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:50.851 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:50.868 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:51:51.920 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:51:51.922 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:53:23.066 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:53:23.083 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:53:24.136 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:53:24.138 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:58:47.183 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:58:47.203 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:58:48.254 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:58:48.256 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:59:49.246 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:59:49.262 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 15:59:50.317 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 15:59:50.320 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:00:59.552 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:00:59.569 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 16:01:00.620 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:01:00.623 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:04:30.586 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:04:30.602 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 16:04:31.654 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:04:31.657 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:08:37.991 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:08:38.007 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 16:08:39.059 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:08:39.061 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:13:28.463 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:13:28.480 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 16:13:29.534 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:13:29.536 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:17:39.133 -!MESSAGE Terminated Launch with connection: 10USB-Blaster on localhost [3-1.6] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:17:39.149 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid --sidp=Not Found] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-08-16 16:17:40.201 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8 - -!ENTRY com.altera.sbtgui.launch 1 0 2013-08-16 16:17:40.203 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid /home/alek/aktualne/vga/software/exe/exe.elf] diff --git a/syn/components/vga/software/.metadata/.mylyn/repositories.xml.zip b/syn/components/vga/software/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index 75a3948..0000000 Binary files a/syn/components/vga/software/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/.log b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/.log deleted file mode 100644 index 447b3c8..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/.log +++ /dev/null @@ -1,3 +0,0 @@ -*** SESSION Aug 10, 2013 12:37:13.43 ------------------------------------------- -*** SESSION Aug 14, 2013 20:54:35.99 ------------------------------------------- -*** SESSION Aug 16, 2013 01:11:35.29 ------------------------------------------- diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376131083987.pdom b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376131083987.pdom deleted file mode 100644 index 3e83f78..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe.1376131083987.pdom and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376131081026.pdom b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376131081026.pdom deleted file mode 100644 index 4c66536..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1376131081026.pdom and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/.log deleted file mode 100644 index e69de29..0000000 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc deleted file mode 100644 index 3d359c7..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc deleted file mode 100644 index e40a130..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp deleted file mode 100644 index 8b13789..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml deleted file mode 100644 index 991fa7c..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml +++ /dev/null @@ -1,12 +0,0 @@ - -
- -
-
-
- - -
-
-
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log deleted file mode 100644 index d573490..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log +++ /dev/null @@ -1,43 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c:71: warning: missing braces around initializer -main.c:71: warning: (near initialization for 'palette2[0]') -main.c: In function 'test_text_mode': -main.c:160: warning: unused variable 'mode_03' -main.c:145: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:407: warning: unused variable 'mode_11' -main.c:392: warning: unused variable 'mode_10' -main.c:377: warning: unused variable 'mode_0f' -main.c:362: warning: unused variable 'mode_0e' -main.c:347: warning: unused variable 'mode_0d' -main.c:332: warning: unused variable 'mode_06' -main.c:317: warning: unused variable 'mode_05' -main.c:301: warning: unused variable 'mode_04' -main.c: At top level: -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:7: warning: 'palette3' defined but not used -main.c:46: warning: 'palette0' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log deleted file mode 100644 index 6abdd49..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log +++ /dev/null @@ -1,180 +0,0 @@ - -**** Build of configuration Nios II for project exe_bsp **** - -make all -Compiling alt_alarm_start.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_alarm_start.o HAL/src/alt_alarm_start.c -Compiling alt_busy_sleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_busy_sleep.o HAL/src/alt_busy_sleep.c -Compiling alt_close.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_close.o HAL/src/alt_close.c -Compiling alt_dcache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush.o HAL/src/alt_dcache_flush.c -Compiling alt_dcache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_all.o HAL/src/alt_dcache_flush_all.c -Compiling alt_dcache_flush_no_writeback.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dcache_flush_no_writeback.o HAL/src/alt_dcache_flush_no_writeback.c -Compiling alt_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev.o HAL/src/alt_dev.c -Compiling alt_dev_llist_insert.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dev_llist_insert.o HAL/src/alt_dev_llist_insert.c -Compiling alt_dma_rxchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_rxchan_open.o HAL/src/alt_dma_rxchan_open.c -Compiling alt_dma_txchan_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_dma_txchan_open.o HAL/src/alt_dma_txchan_open.c -Compiling alt_do_ctors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_ctors.o HAL/src/alt_do_ctors.c -Compiling alt_do_dtors.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_do_dtors.o HAL/src/alt_do_dtors.c -Compiling alt_env_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_env_lock.o HAL/src/alt_env_lock.c -Compiling alt_environ.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_environ.o HAL/src/alt_environ.c -Compiling alt_errno.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_errno.o HAL/src/alt_errno.c -Compiling alt_exception_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_entry.o HAL/src/alt_exception_entry.S -Compiling alt_exception_muldiv.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_muldiv.o HAL/src/alt_exception_muldiv.S -Compiling alt_exception_trap.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_exception_trap.o HAL/src/alt_exception_trap.S -Compiling alt_execve.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_execve.o HAL/src/alt_execve.c -Compiling alt_exit.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_exit.o HAL/src/alt_exit.c -Compiling alt_fcntl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fcntl.o HAL/src/alt_fcntl.c -Compiling alt_fd_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_lock.o HAL/src/alt_fd_lock.c -Compiling alt_fd_unlock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fd_unlock.o HAL/src/alt_fd_unlock.c -Compiling alt_find_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_dev.o HAL/src/alt_find_dev.c -Compiling alt_find_file.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_find_file.o HAL/src/alt_find_file.c -Compiling alt_flash_dev.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_flash_dev.o HAL/src/alt_flash_dev.c -Compiling alt_fork.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fork.o HAL/src/alt_fork.c -Compiling alt_fs_reg.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fs_reg.o HAL/src/alt_fs_reg.c -Compiling alt_fstat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_fstat.o HAL/src/alt_fstat.c -Compiling alt_get_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_get_fd.o HAL/src/alt_get_fd.c -Compiling alt_getchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getchar.o HAL/src/alt_getchar.c -Compiling alt_getpid.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_getpid.o HAL/src/alt_getpid.c -Compiling alt_gettod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gettod.o HAL/src/alt_gettod.c -Compiling alt_gmon.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_gmon.o HAL/src/alt_gmon.c -Compiling alt_icache_flush.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush.o HAL/src/alt_icache_flush.c -Compiling alt_icache_flush_all.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_icache_flush_all.o HAL/src/alt_icache_flush_all.c -Compiling alt_iic.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic.o HAL/src/alt_iic.c -Compiling alt_iic_isr_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_iic_isr_register.o HAL/src/alt_iic_isr_register.c -Compiling alt_instruction_exception_entry.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_entry.o HAL/src/alt_instruction_exception_entry.c -Compiling alt_instruction_exception_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_instruction_exception_register.o HAL/src/alt_instruction_exception_register.c -Compiling alt_io_redirect.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_io_redirect.o HAL/src/alt_io_redirect.c -Compiling alt_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_ioctl.o HAL/src/alt_ioctl.c -Compiling alt_irq_entry.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_irq_entry.o HAL/src/alt_irq_entry.S -Compiling alt_irq_handler.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_handler.o HAL/src/alt_irq_handler.c -Compiling alt_irq_register.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_register.o HAL/src/alt_irq_register.c -Compiling alt_irq_vars.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_irq_vars.o HAL/src/alt_irq_vars.c -Compiling alt_isatty.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_isatty.o HAL/src/alt_isatty.c -Compiling alt_kill.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_kill.o HAL/src/alt_kill.c -Compiling alt_link.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_link.o HAL/src/alt_link.c -Compiling alt_load.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_load.o HAL/src/alt_load.c -Compiling alt_log_macro.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_log_macro.o HAL/src/alt_log_macro.S -Compiling alt_log_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_log_printf.o HAL/src/alt_log_printf.c -Compiling alt_lseek.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_lseek.o HAL/src/alt_lseek.c -Compiling alt_main.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_main.o HAL/src/alt_main.c -Compiling alt_malloc_lock.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_malloc_lock.o HAL/src/alt_malloc_lock.c -Compiling alt_mcount.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_mcount.o HAL/src/alt_mcount.S -Compiling alt_open.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_open.o HAL/src/alt_open.c -Compiling alt_printf.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_printf.o HAL/src/alt_printf.c -Compiling alt_putchar.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putchar.o HAL/src/alt_putchar.c -Compiling alt_putstr.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_putstr.o HAL/src/alt_putstr.c -Compiling alt_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_read.o HAL/src/alt_read.c -Compiling alt_release_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_release_fd.o HAL/src/alt_release_fd.c -Compiling alt_remap_cached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_cached.o HAL/src/alt_remap_cached.c -Compiling alt_remap_uncached.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_remap_uncached.o HAL/src/alt_remap_uncached.c -Compiling alt_rename.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_rename.o HAL/src/alt_rename.c -Compiling alt_sbrk.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_sbrk.o HAL/src/alt_sbrk.c -Compiling alt_settod.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_settod.o HAL/src/alt_settod.c -Compiling alt_software_exception.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/alt_software_exception.o HAL/src/alt_software_exception.S -Compiling alt_stat.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_stat.o HAL/src/alt_stat.c -Compiling alt_tick.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_tick.o HAL/src/alt_tick.c -Compiling alt_times.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_times.o HAL/src/alt_times.c -Compiling alt_uncached_free.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_free.o HAL/src/alt_uncached_free.c -Compiling alt_uncached_malloc.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_uncached_malloc.o HAL/src/alt_uncached_malloc.c -Compiling alt_unlink.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_unlink.o HAL/src/alt_unlink.c -Compiling alt_usleep.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_usleep.o HAL/src/alt_usleep.c -Compiling alt_wait.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_wait.o HAL/src/alt_wait.c -Compiling alt_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/alt_write.o HAL/src/alt_write.c -Compiling altera_nios2_qsys_irq.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/HAL/src/altera_nios2_qsys_irq.o HAL/src/altera_nios2_qsys_irq.c -Compiling crt0.S... -nios2-elf-gcc -MP -MMD -c -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -Wa,-gdwarf2 -o obj/HAL/src/crt0.o HAL/src/crt0.S -Compiling alt_sys_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/alt_sys_init.o alt_sys_init.c -Compiling altera_avalon_jtag_uart_fd.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_fd.o drivers/src/altera_avalon_jtag_uart_fd.c -Compiling altera_avalon_jtag_uart_init.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_init.o drivers/src/altera_avalon_jtag_uart_init.c -Compiling altera_avalon_jtag_uart_ioctl.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o drivers/src/altera_avalon_jtag_uart_ioctl.c -Compiling altera_avalon_jtag_uart_read.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_read.o drivers/src/altera_avalon_jtag_uart_read.c -Compiling altera_avalon_jtag_uart_write.c... -nios2-elf-gcc -xc -MP -MMD -c -I./HAL/inc -I. -I./drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/drivers/src/altera_avalon_jtag_uart_write.o drivers/src/altera_avalon_jtag_uart_write.c -Creating libhal_bsp.a... -rm -f -f libhal_bsp.a -nios2-elf-ar -src libhal_bsp.a obj/HAL/src/alt_alarm_start.o obj/HAL/src/alt_busy_sleep.o obj/HAL/src/alt_close.o obj/HAL/src/alt_dcache_flush.o obj/HAL/src/alt_dcache_flush_all.o obj/HAL/src/alt_dcache_flush_no_writeback.o obj/HAL/src/alt_dev.o obj/HAL/src/alt_dev_llist_insert.o obj/HAL/src/alt_dma_rxchan_open.o obj/HAL/src/alt_dma_txchan_open.o obj/HAL/src/alt_do_ctors.o obj/HAL/src/alt_do_dtors.o obj/HAL/src/alt_env_lock.o obj/HAL/src/alt_environ.o obj/HAL/src/alt_errno.o obj/HAL/src/alt_exception_entry.o obj/HAL/src/alt_exception_muldiv.o obj/HAL/src/alt_exception_trap.o obj/HAL/src/alt_execve.o obj/HAL/src/alt_exit.o obj/HAL/src/alt_fcntl.o obj/HAL/src/alt_fd_lock.o obj/HAL/src/alt_fd_unlock.o obj/HAL/src/alt_find_dev.o obj/HAL/src/alt_find_file.o obj/HAL/src/alt_flash_dev.o obj/HAL/src/alt_fork.o obj/HAL/src/alt_fs_reg.o obj/HAL/src/alt_fstat.o obj/HAL/src/alt_get_fd.o obj/HAL/src/alt_getchar.o obj/HAL/src/alt_getpid.o obj/HAL/src/alt_gettod.o obj/HAL/src/alt_gmon.o obj/HAL/src/alt_icache_flush.o obj/HAL/src/alt_icache_flush_all.o obj/HAL/src/alt_iic.o obj/HAL/src/alt_iic_isr_register.o obj/HAL/src/alt_instruction_exception_entry.o obj/HAL/src/alt_instruction_exception_register.o obj/HAL/src/alt_io_redirect.o obj/HAL/src/alt_ioctl.o obj/HAL/src/alt_irq_entry.o obj/HAL/src/alt_irq_handler.o obj/HAL/src/alt_irq_register.o obj/HAL/src/alt_irq_vars.o obj/HAL/src/alt_isatty.o obj/HAL/src/alt_kill.o obj/HAL/src/alt_link.o obj/HAL/src/alt_load.o obj/HAL/src/alt_log_macro.o obj/HAL/src/alt_log_printf.o obj/HAL/src/alt_lseek.o obj/HAL/src/alt_main.o obj/HAL/src/alt_malloc_lock.o obj/HAL/src/alt_mcount.o obj/HAL/src/alt_open.o obj/HAL/src/alt_printf.o obj/HAL/src/alt_putchar.o obj/HAL/src/alt_putstr.o obj/HAL/src/alt_read.o obj/HAL/src/alt_release_fd.o obj/HAL/src/alt_remap_cached.o obj/HAL/src/alt_remap_uncached.o obj/HAL/src/alt_rename.o obj/HAL/src/alt_sbrk.o obj/HAL/src/alt_settod.o obj/HAL/src/alt_software_exception.o obj/HAL/src/alt_stat.o obj/HAL/src/alt_tick.o obj/HAL/src/alt_times.o obj/HAL/src/alt_uncached_free.o obj/HAL/src/alt_uncached_malloc.o obj/HAL/src/alt_unlink.o obj/HAL/src/alt_usleep.o obj/HAL/src/alt_wait.o obj/HAL/src/alt_write.o obj/HAL/src/altera_nios2_qsys_irq.o obj/HAL/src/crt0.o obj/alt_sys_init.o obj/drivers/src/altera_avalon_jtag_uart_fd.o obj/drivers/src/altera_avalon_jtag_uart_init.o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o obj/drivers/src/altera_avalon_jtag_uart_read.o obj/drivers/src/altera_avalon_jtag_uart_write.o -[BSP build complete] - -**** Build Finished **** diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log b/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log deleted file mode 100644 index 24dc940..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log +++ /dev/null @@ -1,1448 +0,0 @@ - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:125: warning: unused variable 'mode_03' -main.c:110: warning: unused variable 'mode_01' -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -main.c:125: warning: unused variable 'mode_03' -main.c:110: warning: unused variable 'mode_01' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -main.c:125: warning: unused variable 'mode_03' -main.c:110: warning: unused variable 'mode_01' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c: In function 'test_text_mode': -main.c:125: warning: unused variable 'mode_03' -main.c:110: warning: unused variable 'mode_01' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette1[0]') -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'main': -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:278: warning: unused variable 'mode_04' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette1[0]') -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:122: warning: unused variable 'mode_01' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: In function 'main': -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:324: warning: unused variable 'mode_0d' -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:137: warning: unused variable 'mode_03' -main.c:122: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:324: warning: unused variable 'mode_0d' -main.c:309: warning: unused variable 'mode_06' -main.c:294: warning: unused variable 'mode_05' -main.c:278: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette0[0]') -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette0[0]') -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c: In function 'test_text_mode': -main.c:149: warning: unused variable 'mode_03' -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:134: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:351: warning: unused variable 'mode_0e' -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:336: warning: unused variable 'mode_0d' -main.c:321: warning: unused variable 'mode_06' -main.c:306: warning: unused variable 'mode_05' -main.c:290: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -main.c:9: warning: (near initialization for 'palette3[0]') -Info: Linking exe.elf -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette0[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:60: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:60: warning: (near initialization for 'palette1[0]') -main.c:71: warning: missing braces around initializer -main.c:71: warning: (near initialization for 'palette2[0]') -main.c: In function 'test_text_mode': -main.c:160: warning: unused variable 'mode_03' -main.c:145: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:377: warning: unused variable 'mode_0f' -main.c:362: warning: unused variable 'mode_0e' -main.c:347: warning: unused variable 'mode_0d' -main.c:332: warning: unused variable 'mode_06' -main.c:317: warning: unused variable 'mode_05' -main.c:301: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:46: warning: 'palette0' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c:71: warning: missing braces around initializer -main.c:71: warning: (near initialization for 'palette2[0]') -main.c: In function 'test_text_mode': -main.c:160: warning: unused variable 'mode_03' -main.c:145: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:392: warning: unused variable 'mode_10' -main.c:377: warning: unused variable 'mode_0f' -main.c:362: warning: unused variable 'mode_0e' -main.c:347: warning: unused variable 'mode_0d' -main.c:332: warning: unused variable 'mode_06' -main.c:317: warning: unused variable 'mode_05' -main.c:301: warning: unused variable 'mode_04' -main.c: At top level: -main.c:7: warning: 'palette3' defined but not used -main.c:46: warning: 'palette0' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** - -**** Build of configuration Nios II for project exe **** - -make all -Info: Building ../exe_bsp/ -make --no-print-directory -C ../exe_bsp/ -[BSP build complete] -Info: Compiling main.c to obj/default/main.o -nios2-elf-gcc -xc -MP -MMD -c -I../exe_bsp//HAL/inc -I../exe_bsp/ -I../exe_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DSMALL_C_LIB -DALT_SINGLE_THREADED -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/main.o main.c -main.c:9: warning: missing braces around initializer -Info: Linking exe.elf -main.c:9: warning: (near initialization for 'palette3[0]') -nios2-elf-g++ -T'../exe_bsp//linker.x' -msys-crt0='../exe_bsp//obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../exe_bsp/ -Wl,--defsym,exit=_exit -msmallc -Wl,-Map=exe.map -O2 -g -Wall -EL -mno-hw-div -mno-hw-mul -mno-hw-mulx -o exe.elf obj/default/main.o -lm -main.c:48: warning: missing braces around initializer -main.c:48: warning: (near initialization for 'palette0[0]') -main.c:60: warning: missing braces around initializer -main.c:60: warning: (near initialization for 'palette1[0]') -main.c:71: warning: missing braces around initializer -main.c:71: warning: (near initialization for 'palette2[0]') -main.c: In function 'test_text_mode': -main.c:160: warning: unused variable 'mode_03' -main.c:145: warning: unused variable 'mode_01' -main.c: In function 'main': -main.c:407: warning: unused variable 'mode_11' -main.c:392: warning: unused variable 'mode_10' -main.c:377: warning: unused variable 'mode_0f' -main.c:362: warning: unused variable 'mode_0e' -main.c:347: warning: unused variable 'mode_0d' -main.c:332: warning: unused variable 'mode_06' -main.c:317: warning: unused variable 'mode_05' -main.c:301: warning: unused variable 'mode_04' -main.c: At top level: -nios2-elf-insert exe.elf --thread_model hal --cpu_name nios2_qsys_0 --qsys true --simulation_enabled false --stderr_dev jtag_uart_0 --stdin_dev jtag_uart_0 --stdout_dev jtag_uart_0 --sopc_system_name vga_soc --quartus_project_dir "/home/alek/aktualne/vga" --sopcinfo /home/alek/aktualne/vga/software/exe_bsp/../../vga_soc.sopcinfo -main.c:7: warning: 'palette3' defined but not used -main.c:46: warning: 'palette0' defined but not used -main.c:58: warning: 'palette1' defined but not used -Info: (exe.elf) 11 KBytes program size (code + initialized data). -Info: 20 KBytes free for stack + heap. -Info: Creating exe.objdump -nios2-elf-objdump --disassemble --syms --all-header --source exe.elf >exe.objdump -[exe build complete] - -**** Build Finished **** diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/0/b0bc1fdf7b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/0/b0bc1fdf7b0600131fa2b8de72b0e3dd deleted file mode 100644 index 85e66e8..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/0/b0bc1fdf7b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,518 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/16/c089f5bb780600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/16/c089f5bb780600131fa2b8de72b0e3dd deleted file mode 100644 index 855e105..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/16/c089f5bb780600131fa2b8de72b0e3dd +++ /dev/null @@ -1,433 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x80); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/24/70aa28397a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/24/70aa28397a0600131fa2b8de72b0e3dd deleted file mode 100644 index fbc08e7..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/24/70aa28397a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,503 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/30584dfd7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/30584dfd7d0600131fa2b8de72b0e3dd deleted file mode 100644 index 530bc66..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/25/30584dfd7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,600 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/27/50d5f4907d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/27/50d5f4907d0600131fa2b8de72b0e3dd deleted file mode 100644 index 16197c9..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/27/50d5f4907d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,592 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/28/f0f1e0d47c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/28/f0f1e0d47c0600131fa2b8de72b0e3dd deleted file mode 100644 index 5bc7458..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/28/f0f1e0d47c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,534 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01 + 4, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/30495563790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/30495563790600131fa2b8de72b0e3dd deleted file mode 100644 index 03fecc9..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/30495563790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,443 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/b0e88b3f790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/b0e88b3f790600131fa2b8de72b0e3dd deleted file mode 100644 index 48f54ca..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/2a/b0e88b3f790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,441 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/32/e0c61a157a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/32/e0c61a157a0600131fa2b8de72b0e3dd deleted file mode 100644 index c81f12c..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/32/e0c61a157a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,491 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/36/c07126e77a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/36/c07126e77a0600131fa2b8de72b0e3dd deleted file mode 100644 index e7bad44..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/36/c07126e77a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,512 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3b/40e297347b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3b/40e297347b0600131fa2b8de72b0e3dd deleted file mode 100644 index a66e2f5..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3b/40e297347b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,515 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3f/a084f0ce7b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3f/a084f0ce7b0600131fa2b8de72b0e3dd deleted file mode 100644 index 63a3cfb..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/3f/a084f0ce7b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,515 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/42/905fb5337d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/42/905fb5337d0600131fa2b8de72b0e3dd deleted file mode 100644 index 741c9bd..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/42/905fb5337d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,566 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/10b57e457c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/10b57e457c0600131fa2b8de72b0e3dd deleted file mode 100644 index 931ba76..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/47/10b57e457c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,534 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0x81); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/49/c0169b24790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/49/c0169b24790600131fa2b8de72b0e3dd deleted file mode 100644 index 7138a4c..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/49/c0169b24790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,437 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/4d/20eb8d9d790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/4d/20eb8d9d790600131fa2b8de72b0e3dd deleted file mode 100644 index e40bd07..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/4d/20eb8d9d790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,458 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0e; - int mode_num = 0x0e; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/50a2504f7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/50a2504f7d0600131fa2b8de72b0e3dd deleted file mode 100644 index c1147d9..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/50a2504f7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,577 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0e5fc567d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0e5fc567d0600131fa2b8de72b0e3dd deleted file mode 100644 index 4888f74..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0e5fc567d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,577 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/40557ef67d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/40557ef67d0600131fa2b8de72b0e3dd deleted file mode 100644 index e316886..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/40557ef67d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,599 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/507ed68d7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/507ed68d7d0600131fa2b8de72b0e3dd deleted file mode 100644 index 8df59d1..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/51/507ed68d7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,577 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/55/10d68f937e0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/55/10d68f937e0600131fa2b8de72b0e3dd deleted file mode 100644 index ee66f5b..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/55/10d68f937e0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,646 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_12[] = - { - /* index=0x1b vga mode 0x12 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_12; - int mode_num = 0x12; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80 + 79, 0x81); - } - if(mode_num == 0x12) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/00d33795790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/00d33795790600131fa2b8de72b0e3dd deleted file mode 100644 index 7157625..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5b/00d33795790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,458 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5c/30a9aef57d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5c/30a9aef57d0600131fa2b8de72b0e3dd deleted file mode 100644 index fa9f22f..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5c/30a9aef57d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,597 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/808a18d2790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/808a18d2790600131fa2b8de72b0e3dd deleted file mode 100644 index ce5d3d4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/808a18d2790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,458 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0e; - int mode_num = 0x0e; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d || mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/90b33f1aa90100131170edee8bf19551 b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/90b33f1aa90100131170edee8bf19551 deleted file mode 100755 index 9311c92..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5e/90b33f1aa90100131170edee8bf19551 +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# This script creates the hello_world application in this directory. - - -BSP_DIR=../exe_bsp -QUARTUS_PROJECT_DIR=../../ -NIOS2_APP_GEN_ARGS="--elf-name exe.elf --set OBJDUMP_INCLUDE_SOURCE 1 --src-files hello_world.c" - - -# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set. -# This variable is required for the command line tools to execute correctly. -if [ -z "${SOPC_KIT_NIOS2}" ] -then - echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set! - exit 1 -fi - - -# Also make sure that the APP has not been created already. Check for -# existence of Makefile in the app directory -if [ -f ./Makefile ] -then - echo Application has already been created! Delete Makefile if you want to create a new application makefile - exit 1 -fi - - -# We are selecting hal_default bsp because it supports this application. -# Check to see if the hal_default has already been generated by checking for -# existence of the public.mk file. If not, we need to run -# create-this-bsp file to generate the bsp. -if [ ! -f ${BSP_DIR}/public.mk ]; then - # Since BSP doesn't exist, create the BSP - # Pass any command line arguments passed to this script to the BSP. - pushd ${BSP_DIR} >> /dev/null - ./create-this-bsp "$@" || { - echo "create-this-bsp failed" - exit 1 - } - popd >> /dev/null -fi - - -# Don't run make if create-this-app script is called with --no-make arg -SKIP_MAKE= -while [ $# -gt 0 ] -do - case "$1" in - --no-make) - SKIP_MAKE=1 - ;; - esac - shift -done - - -# Now we also need to go copy the sources for this application to the -# local directory. -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || { - echo "failed during copying example source files" - exit 1 -} - -find "${SOPC_KIT_NIOS2}/examples/software/hello_world/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || { - echo "failed copying readme file" -} - -if [ -d "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" ] -then - cp -RL "${SOPC_KIT_NIOS2}/examples/software/hello_world/system" . || { - echo "failed during copying project support files" - exit 1 - } -fi - -chmod -R +w . || { - echo "failed during changing file permissions" - exit 1 -} - -cmd="nios2-app-generate-makefile --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}" - -echo "create-this-app: Running \"${cmd}\"" -$cmd || { - echo "nios2-app-generate-makefile failed" - exit 1 -} - -if [ -z "$SKIP_MAKE" ]; then - cmd="make" - - echo "create-this-app: Running \"$cmd\"" - $cmd || { - echo "make failed" - exit 1 - } - - echo - echo "To download and run the application:" - echo " 1. Make sure the board is connected to the system." - echo " 2. Run 'nios2-configure-sof ' to configure the FPGA with the hardware design." - echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell." - echo " 4. Run 'make download-elf' from the application directory." - echo - echo "To debug the application:" - echo " Import the project into Nios II Software Build Tools for Eclipse." - echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information." - echo - echo -e "" -fi - - -exit 0 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5f/d09eec2e7b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5f/d09eec2e7b0600131fa2b8de72b0e3dd deleted file mode 100644 index 1af4068..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/5f/d09eec2e7b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,512 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0a6836c7e0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0a6836c7e0600131fa2b8de72b0e3dd deleted file mode 100644 index 2e647a6..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0a6836c7e0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,616 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_12[] = - { - /* index=0x1b vga mode 0x12 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_12; - int mode_num = 0x12; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80 + 79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/6e/70082ac37c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/6e/70082ac37c0600131fa2b8de72b0e3dd deleted file mode 100644 index 31ff562..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/6e/70082ac37c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,534 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/e027be357d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/e027be357d0600131fa2b8de72b0e3dd deleted file mode 100644 index 23295b2..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7/e027be357d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,577 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static Bit8u palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/75/20aa8bf5780600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/75/20aa8bf5780600131fa2b8de72b0e3dd deleted file mode 100644 index 338ceaa..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/75/20aa8bf5780600131fa2b8de72b0e3dd +++ /dev/null @@ -1,437 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/6017aa3e7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/6017aa3e7d0600131fa2b8de72b0e3dd deleted file mode 100644 index 2530fcc..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/6017aa3e7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,577 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/d0e8502d7e0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/d0e8502d7e0600131fa2b8de72b0e3dd deleted file mode 100644 index b52e7d0..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/76/d0e8502d7e0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,601 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80 + 79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a0a1e32f7e0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a0a1e32f7e0600131fa2b8de72b0e3dd deleted file mode 100644 index ea64922..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/7c/a0a1e32f7e0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,616 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_12[] = - { - /* index=0x1b vga mode 0x12 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80 + 79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/86/602a23a17a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/86/602a23a17a0600131fa2b8de72b0e3dd deleted file mode 100644 index d176c2d..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/86/602a23a17a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,506 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8a/503c1c997d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8a/503c1c997d0600131fa2b8de72b0e3dd deleted file mode 100644 index b69cf59..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8a/503c1c997d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,592 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/a0cfdb427c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/a0cfdb427c0600131fa2b8de72b0e3dd deleted file mode 100644 index aa4abb3..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/8f/a0cfdb427c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,527 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/92/40ce01047e0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/92/40ce01047e0600131fa2b8de72b0e3dd deleted file mode 100644 index d6a0b36..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/92/40ce01047e0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,600 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 479*80, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/97/300fceed7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/97/300fceed7d0600131fa2b8de72b0e3dd deleted file mode 100644 index a619b71..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/97/300fceed7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,595 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; -static unsigned char palette2[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x2a,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x15, 0x00,0x00,0x3f, 0x00,0x2a,0x15, 0x00,0x2a,0x3f, 0x2a,0x00,0x15, 0x2a,0x00,0x3f, 0x2a,0x2a,0x15, 0x2a,0x2a,0x3f, - 0x00,0x15,0x00, 0x00,0x15,0x2a, 0x00,0x3f,0x00, 0x00,0x3f,0x2a, 0x2a,0x15,0x00, 0x2a,0x15,0x2a, 0x2a,0x3f,0x00, 0x2a,0x3f,0x2a, - 0x00,0x15,0x15, 0x00,0x15,0x3f, 0x00,0x3f,0x15, 0x00,0x3f,0x3f, 0x2a,0x15,0x15, 0x2a,0x15,0x3f, 0x2a,0x3f,0x15, 0x2a,0x3f,0x3f, - 0x15,0x00,0x00, 0x15,0x00,0x2a, 0x15,0x2a,0x00, 0x15,0x2a,0x2a, 0x3f,0x00,0x00, 0x3f,0x00,0x2a, 0x3f,0x2a,0x00, 0x3f,0x2a,0x2a, - 0x15,0x00,0x15, 0x15,0x00,0x3f, 0x15,0x2a,0x15, 0x15,0x2a,0x3f, 0x3f,0x00,0x15, 0x3f,0x00,0x3f, 0x3f,0x2a,0x15, 0x3f,0x2a,0x3f, - 0x15,0x15,0x00, 0x15,0x15,0x2a, 0x15,0x3f,0x00, 0x15,0x3f,0x2a, 0x3f,0x15,0x00, 0x3f,0x15,0x2a, 0x3f,0x3f,0x00, 0x3f,0x3f,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette2[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_11[] = - { - /* index=0x1a vga mode 0x11 */ - 80, 29, 16, 0x00, 0x00, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xe3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_11; - int mode_num = 0x11; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - } - if(mode_num == 0x10) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80+79, 0x81); - } - else if(mode_num == 0x11) { - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/9e/d07531b97a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/9e/d07531b97a0600131fa2b8de72b0e3dd deleted file mode 100644 index 567ebae..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/9e/d07531b97a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,509 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a2/709586e1790600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a2/709586e1790600131fa2b8de72b0e3dd deleted file mode 100644 index bd9c5e0..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a2/709586e1790600131fa2b8de72b0e3dd +++ /dev/null @@ -1,476 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0e; - int mode_num = 0x0e; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a4/106a50f17b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a4/106a50f17b0600131fa2b8de72b0e3dd deleted file mode 100644 index ac5786e..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/a4/106a50f17b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,524 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/ae/3039c9e1780600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/ae/3039c9e1780600131fa2b8de72b0e3dd deleted file mode 100644 index edb1bf4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/ae/3039c9e1780600131fa2b8de72b0e3dd +++ /dev/null @@ -1,435 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0d; - int mode_num = 0x0d; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60c2ff097a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60c2ff097a0600131fa2b8de72b0e3dd deleted file mode 100644 index d7c5e13..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60c2ff097a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,476 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0e; - int mode_num = 0x0e; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bb/f0f34f0c7a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bb/f0f34f0c7a0600131fa2b8de72b0e3dd deleted file mode 100644 index 0351b12..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bb/f0f34f0c7a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,491 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette1[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0e; - int mode_num = 0x0e; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bd/3043c6eb7b0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bd/3043c6eb7b0600131fa2b8de72b0e3dd deleted file mode 100644 index f89efa4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/bd/3043c6eb7b0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,518 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/c8/705fa40a7d0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/c8/705fa40a7d0600131fa2b8de72b0e3dd deleted file mode 100644 index eb5eac8..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/c8/705fa40a7d0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,549 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_10; - int mode_num = 0x10; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d3/90cb5d1b7c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d3/90cb5d1b7c0600131fa2b8de72b0e3dd deleted file mode 100644 index 38f7e3b..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d3/90cb5d1b7c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,524 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d5/d0a502fe7a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d5/d0a502fe7a0600131fa2b8de72b0e3dd deleted file mode 100644 index e148b71..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/d5/d0a502fe7a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,512 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dc/f0e2a1257a0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dc/f0e2a1257a0600131fa2b8de72b0e3dd deleted file mode 100644 index f31e653..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dc/f0e2a1257a0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,491 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dd/80ec70fb7c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dd/80ec70fb7c0600131fa2b8de72b0e3dd deleted file mode 100644 index 31ff562..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/dd/80ec70fb7c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,534 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/d0f65d14a90100131170edee8bf19551 b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/d0f65d14a90100131170edee8bf19551 deleted file mode 100644 index 7d0742f..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/e9/d0f65d14a90100131170edee8bf19551 +++ /dev/null @@ -1,26 +0,0 @@ -Readme - Hello World Software Example - -DESCRIPTION: -Simple program that prints "Hello from Nios II" - -The memory footprint of this hosted application is intended to be small (under 100 kbytes) by default -using a standard reference deisgn. - -For an even smaller, reduced footprint version of this template, and an explanation of how -to reduce the memory footprint for a given application, see the -"small_hello_world" template. - - -PERIPHERALS USED: -This example exercises the following peripherals: -- STDOUT device (UART or JTAG UART) - -SOFTWARE SOURCE FILES: -This example includes the following software source files: -- hello_world.c: Everyone needs a Hello World program, right? - -BOARD/HOST REQUIREMENTS: -This example requires only a JTAG connection with a Nios Development board. If -the host communication settings are changed from JTAG UART (default) to use a -conventional UART, a serial cable between board DB-9 connector and the host is -required. diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fa/60c082fe7c0600131fa2b8de72b0e3dd b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fa/60c082fe7c0600131fa2b8de72b0e3dd deleted file mode 100644 index b4be79d..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fa/60c082fe7c0600131fa2b8de72b0e3dd +++ /dev/null @@ -1,549 +0,0 @@ -#include -#include - -#include "system.h" -#include "io.h" - -static unsigned char palette3[256][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x05,0x05,0x05, 0x08,0x08,0x08, 0x0b,0x0b,0x0b, 0x0e,0x0e,0x0e, 0x11,0x11,0x11, 0x14,0x14,0x14, 0x18,0x18,0x18, - 0x1c,0x1c,0x1c, 0x20,0x20,0x20, 0x24,0x24,0x24, 0x28,0x28,0x28, 0x2d,0x2d,0x2d, 0x32,0x32,0x32, 0x38,0x38,0x38, 0x3f,0x3f,0x3f, - 0x00,0x00,0x3f, 0x10,0x00,0x3f, 0x1f,0x00,0x3f, 0x2f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x2f, 0x3f,0x00,0x1f, 0x3f,0x00,0x10, - 0x3f,0x00,0x00, 0x3f,0x10,0x00, 0x3f,0x1f,0x00, 0x3f,0x2f,0x00, 0x3f,0x3f,0x00, 0x2f,0x3f,0x00, 0x1f,0x3f,0x00, 0x10,0x3f,0x00, - 0x00,0x3f,0x00, 0x00,0x3f,0x10, 0x00,0x3f,0x1f, 0x00,0x3f,0x2f, 0x00,0x3f,0x3f, 0x00,0x2f,0x3f, 0x00,0x1f,0x3f, 0x00,0x10,0x3f, - 0x1f,0x1f,0x3f, 0x27,0x1f,0x3f, 0x2f,0x1f,0x3f, 0x37,0x1f,0x3f, 0x3f,0x1f,0x3f, 0x3f,0x1f,0x37, 0x3f,0x1f,0x2f, 0x3f,0x1f,0x27, - - 0x3f,0x1f,0x1f, 0x3f,0x27,0x1f, 0x3f,0x2f,0x1f, 0x3f,0x37,0x1f, 0x3f,0x3f,0x1f, 0x37,0x3f,0x1f, 0x2f,0x3f,0x1f, 0x27,0x3f,0x1f, - 0x1f,0x3f,0x1f, 0x1f,0x3f,0x27, 0x1f,0x3f,0x2f, 0x1f,0x3f,0x37, 0x1f,0x3f,0x3f, 0x1f,0x37,0x3f, 0x1f,0x2f,0x3f, 0x1f,0x27,0x3f, - 0x2d,0x2d,0x3f, 0x31,0x2d,0x3f, 0x36,0x2d,0x3f, 0x3a,0x2d,0x3f, 0x3f,0x2d,0x3f, 0x3f,0x2d,0x3a, 0x3f,0x2d,0x36, 0x3f,0x2d,0x31, - 0x3f,0x2d,0x2d, 0x3f,0x31,0x2d, 0x3f,0x36,0x2d, 0x3f,0x3a,0x2d, 0x3f,0x3f,0x2d, 0x3a,0x3f,0x2d, 0x36,0x3f,0x2d, 0x31,0x3f,0x2d, - 0x2d,0x3f,0x2d, 0x2d,0x3f,0x31, 0x2d,0x3f,0x36, 0x2d,0x3f,0x3a, 0x2d,0x3f,0x3f, 0x2d,0x3a,0x3f, 0x2d,0x36,0x3f, 0x2d,0x31,0x3f, - 0x00,0x00,0x1c, 0x07,0x00,0x1c, 0x0e,0x00,0x1c, 0x15,0x00,0x1c, 0x1c,0x00,0x1c, 0x1c,0x00,0x15, 0x1c,0x00,0x0e, 0x1c,0x00,0x07, - 0x1c,0x00,0x00, 0x1c,0x07,0x00, 0x1c,0x0e,0x00, 0x1c,0x15,0x00, 0x1c,0x1c,0x00, 0x15,0x1c,0x00, 0x0e,0x1c,0x00, 0x07,0x1c,0x00, - 0x00,0x1c,0x00, 0x00,0x1c,0x07, 0x00,0x1c,0x0e, 0x00,0x1c,0x15, 0x00,0x1c,0x1c, 0x00,0x15,0x1c, 0x00,0x0e,0x1c, 0x00,0x07,0x1c, - - 0x0e,0x0e,0x1c, 0x11,0x0e,0x1c, 0x15,0x0e,0x1c, 0x18,0x0e,0x1c, 0x1c,0x0e,0x1c, 0x1c,0x0e,0x18, 0x1c,0x0e,0x15, 0x1c,0x0e,0x11, - 0x1c,0x0e,0x0e, 0x1c,0x11,0x0e, 0x1c,0x15,0x0e, 0x1c,0x18,0x0e, 0x1c,0x1c,0x0e, 0x18,0x1c,0x0e, 0x15,0x1c,0x0e, 0x11,0x1c,0x0e, - 0x0e,0x1c,0x0e, 0x0e,0x1c,0x11, 0x0e,0x1c,0x15, 0x0e,0x1c,0x18, 0x0e,0x1c,0x1c, 0x0e,0x18,0x1c, 0x0e,0x15,0x1c, 0x0e,0x11,0x1c, - 0x14,0x14,0x1c, 0x16,0x14,0x1c, 0x18,0x14,0x1c, 0x1a,0x14,0x1c, 0x1c,0x14,0x1c, 0x1c,0x14,0x1a, 0x1c,0x14,0x18, 0x1c,0x14,0x16, - 0x1c,0x14,0x14, 0x1c,0x16,0x14, 0x1c,0x18,0x14, 0x1c,0x1a,0x14, 0x1c,0x1c,0x14, 0x1a,0x1c,0x14, 0x18,0x1c,0x14, 0x16,0x1c,0x14, - 0x14,0x1c,0x14, 0x14,0x1c,0x16, 0x14,0x1c,0x18, 0x14,0x1c,0x1a, 0x14,0x1c,0x1c, 0x14,0x1a,0x1c, 0x14,0x18,0x1c, 0x14,0x16,0x1c, - 0x00,0x00,0x10, 0x04,0x00,0x10, 0x08,0x00,0x10, 0x0c,0x00,0x10, 0x10,0x00,0x10, 0x10,0x00,0x0c, 0x10,0x00,0x08, 0x10,0x00,0x04, - 0x10,0x00,0x00, 0x10,0x04,0x00, 0x10,0x08,0x00, 0x10,0x0c,0x00, 0x10,0x10,0x00, 0x0c,0x10,0x00, 0x08,0x10,0x00, 0x04,0x10,0x00, - - 0x00,0x10,0x00, 0x00,0x10,0x04, 0x00,0x10,0x08, 0x00,0x10,0x0c, 0x00,0x10,0x10, 0x00,0x0c,0x10, 0x00,0x08,0x10, 0x00,0x04,0x10, - 0x08,0x08,0x10, 0x0a,0x08,0x10, 0x0c,0x08,0x10, 0x0e,0x08,0x10, 0x10,0x08,0x10, 0x10,0x08,0x0e, 0x10,0x08,0x0c, 0x10,0x08,0x0a, - 0x10,0x08,0x08, 0x10,0x0a,0x08, 0x10,0x0c,0x08, 0x10,0x0e,0x08, 0x10,0x10,0x08, 0x0e,0x10,0x08, 0x0c,0x10,0x08, 0x0a,0x10,0x08, - 0x08,0x10,0x08, 0x08,0x10,0x0a, 0x08,0x10,0x0c, 0x08,0x10,0x0e, 0x08,0x10,0x10, 0x08,0x0e,0x10, 0x08,0x0c,0x10, 0x08,0x0a,0x10, - 0x0b,0x0b,0x10, 0x0c,0x0b,0x10, 0x0d,0x0b,0x10, 0x0f,0x0b,0x10, 0x10,0x0b,0x10, 0x10,0x0b,0x0f, 0x10,0x0b,0x0d, 0x10,0x0b,0x0c, - 0x10,0x0b,0x0b, 0x10,0x0c,0x0b, 0x10,0x0d,0x0b, 0x10,0x0f,0x0b, 0x10,0x10,0x0b, 0x0f,0x10,0x0b, 0x0d,0x10,0x0b, 0x0c,0x10,0x0b, - 0x0b,0x10,0x0b, 0x0b,0x10,0x0c, 0x0b,0x10,0x0d, 0x0b,0x10,0x0f, 0x0b,0x10,0x10, 0x0b,0x0f,0x10, 0x0b,0x0d,0x10, 0x0b,0x0c,0x10, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 -}; - -static unsigned char palette0[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, 0x2a,0x2a,0x2a, - 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f, 0x3f,0x3f,0x3f -}; - -static unsigned char palette1[63+1][3]= -{ - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x00,0x00,0x00, 0x00,0x00,0x2a, 0x00,0x2a,0x00, 0x00,0x2a,0x2a, 0x2a,0x00,0x00, 0x2a,0x00,0x2a, 0x2a,0x15,0x00, 0x2a,0x2a,0x2a, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f, - 0x15,0x15,0x15, 0x15,0x15,0x3f, 0x15,0x3f,0x15, 0x15,0x3f,0x3f, 0x3f,0x15,0x15, 0x3f,0x15,0x3f, 0x3f,0x3f,0x15, 0x3f,0x3f,0x3f -}; - -void test_mode13() { - int i; - - /* - unsigned char *mem = (unsigned char *)VGA_0_MEM_BASE; - - mem[0] = 1; - mem[1] = 2; - mem[2] = 3; - mem[3] = 4; - */ - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, (i%2)? 2 : 1); - - for(i=0; i<320; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 63680+i, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i*320, (i%2)? 2 : 1); - - for(i=0; i<200; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 319+i*320, (i%2)? 2 : 1); - - for(i=0; i<64000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, i, i); - - - /* - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0xFF); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, 0x00); - */ -} - -void test_text_mode() { - int i; - - //disable chained mode and odd/even mode - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 4); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x6); - - //enable page 2 write - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - - //load font data - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 1, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 2, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 3, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 4, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 5, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 6, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 7, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 8, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 9, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 10, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 11, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 12, 0x18); - IOWR_8DIRECT(VGA_0_MEM_BASE, 13, 0x24); - IOWR_8DIRECT(VGA_0_MEM_BASE, 14, 0x42); - IOWR_8DIRECT(VGA_0_MEM_BASE, 15, 0x81); - - unsigned char mode_01[] = - { - /* index=0x17 vga mode 0x01 */ - 40, 24, 16, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x08, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_03[] = - { - /* index=0x18 vga mode 0x03 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x67, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_07[] = - { - /* index=0x19 vga mode 0x07 */ - 80, 24, 16, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x00, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x66, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x0e, 0x00, 0x0f, 0x08, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_07; - int mode_num = 0x07; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //clear memory - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + i, 0x00); - for(i=0; i<4000; i++) IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + i, 0x00); - - // for mode 0,3 - if(mode_num == 0x01 || mode_num == 0x03) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18001, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1804f, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1920 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1999, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 160 - 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 3999, 0x04); - } - - //for mode 7 - if(mode_num == 0x07) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 160 -1, 0x04); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 3840 + 1, 0x04); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x10000 + 4000 - 1, 0x04); - } -} - -int main() { - - IOWR(VGA_0_SYS_BASE, 0, 0xC000); - - int i; - for(i=0; i<128; i++) { - IOWR(VGA_0_SYS_BASE, i, ('0'+(i%10))); - } - - usleep(1000000); - - IOWR(VGA_0_SYS_BASE, 0, 0x8000); - - //-------------------- - - //load dac - IOWR_8DIRECT(VGA_0_IO_C_BASE, 8, 0); - - /* - for(i=0; i<256; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette3[i][2]); - } - */ - - for(i=0; i<64; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][0]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][1]); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 9, palette0[i][2]); - } - - - //test_mode13(); - //return 0; - - //test_text_mode(); - //return 0; - - unsigned char mode_04[] = - { - /* index=0x04 vga mode 0x04 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char mode_05[] = - { - /* index=0x05 vga mode 0x05 */ - 40, 24, 8, 0x00, 0x08, /* tw, th-1, ch, slength */ - 0x09, 0x03, 0x00, 0x02, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2, - 0xff, /* crtc_regs */ - 0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x03, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_06[] = - { - /* index=0x06 vga mode 0x06 */ - 80, 24, 8, 0x00, 0x10, /* tw, th-1, ch, slength */ - 0x01, 0x01, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2, - 0xff, /* crtc_regs */ - 0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0d[] = - { - /* index=0x0d vga mode 0x0d */ - 40, 24, 8, 0x00, 0x20, /* tw, th-1, ch, slength */ - 0x09, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0e[] = - { - /* index=0x0e vga mode 0x0e */ - 80, 24, 8, 0x00, 0x40, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0x63, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char mode_0f[] = - { - /* index=0x11 vga mode 0x0f */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - unsigned char node_10[] = - { - /* index=0x12 vga mode 0x10 */ - 80, 24, 14, 0x00, 0x80, /* tw, th-1, ch, slength */ - 0x01, 0x0f, 0x00, 0x06, /* sequ_regs */ - 0xa3, /* miscreg */ - 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0xbf, 0x1f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3, - 0xff, /* crtc_regs */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x01, 0x00, 0x0f, 0x00, /* actl_regs */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, /* grdc_regs */ - }; - - unsigned char *mode = mode_0f; - int mode_num = 0x0f; - - //load sequencer - for(i=0; i<4; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, i+1); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, mode[5+i]); - } - - //load misc - IOWR_8DIRECT(VGA_0_IO_C_BASE, 2, mode[9]); - - //load crtc -- disable protect - if(mode_num != 0x07) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_D_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_D_BASE, 5, mode[10+i]); - } - } - else { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, 0x11); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[27] & 0x7F); - - for(i=0; i<0x18; i++) { - IOWR_8DIRECT(VGA_0_IO_B_BASE, 4, i); - IOWR_8DIRECT(VGA_0_IO_B_BASE, 5, mode[10+i]); - } - } - //load attrib - for(i=0; i<0x14; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, 0x20 | i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0, mode[35+i]); - } - - //load graphic - for(i=0; i<0x09; i++) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xE, i); - IOWR_8DIRECT(VGA_0_IO_C_BASE, 0xF, mode[55+i]); - } - - //draw pixels - if(mode_num == 0x04 || mode_num == 0x05) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, (2 << 6) | (2 << 4) | (2 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (2 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, (3 << 6) | (3 << 4) | (3 << 2) | (1 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, (3 << 6) | (3 << 4) | (3 << 2) | (3 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, (2 << 6) | (2 << 4) | (2 << 2) | (2 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, (3 << 6) | (2 << 4) | (1 << 2) | (3 << 0)); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, (1 << 6) | (1 << 4) | (1 << 2) | (1 << 0)); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, (3 << 6) | (2 << 4) | (3 << 2) | (2 << 0)); - } - if(mode_num == 0x06) { - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 1, 0x81); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 79, 0x81); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80, 0xFF); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000, 0x42); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99, 0xb0); - - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*99 + 79, 0xd0); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*99 + 79, 0xb0); - - //for(i=0; i<100; i++) { - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x18000 + 80*i, 0x80); - // IOWR_8DIRECT(VGA_0_MEM_BASE, 0x1A000 + 80*i, 0x80); - //} - } - - - if(mode_num == 0x0d) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 39, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*40+39, 0x81); - } - if(mode_num == 0x0e) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xe); - IOWR_8DIRECT(VGA_0_MEM_BASE, 199*80+79, 0x81); - } - if(mode_num == 0x0f) { - IOWR_8DIRECT(VGA_0_IO_C_BASE, 4, 2); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 0, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x1); - IOWR_8DIRECT(VGA_0_MEM_BASE, 79, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x5); - IOWR_8DIRECT(VGA_0_MEM_BASE, 80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x2); - IOWR_8DIRECT(VGA_0_MEM_BASE, 81, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x4); - IOWR_8DIRECT(VGA_0_MEM_BASE, 82, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0x8); - IOWR_8DIRECT(VGA_0_MEM_BASE, 83, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 84, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80, 0x81); - - IOWR_8DIRECT(VGA_0_IO_C_BASE, 5, 0xf); - IOWR_8DIRECT(VGA_0_MEM_BASE, 349*80 + 79, 0xc1); - - } - return 0; -} - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fc/80db2f17a90100131170edee8bf19551 b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fc/80db2f17a90100131170edee8bf19551 deleted file mode 100644 index a04d9c6..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.history/fc/80db2f17a90100131170edee8bf19551 +++ /dev/null @@ -1,24 +0,0 @@ -/* - * "Hello World" example. - * - * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on - * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example - * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT - * device in your system's hardware. - * The memory footprint of this hosted application is ~69 kbytes by default - * using the standard reference design. - * - * For a reduced footprint version of this template, and an explanation of how - * to reduce the memory footprint for a given application, see the - * "small_hello_world" template. - * - */ - -#include - -int main() -{ - printf("Hello from Nios II!\n"); - - return 0; -} diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index deleted file mode 100644 index d6d025e..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/history.index and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index deleted file mode 100644 index ddb2e41..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.indexes/properties.index and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.markers b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.markers deleted file mode 100644 index cea476b..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe/.markers and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index deleted file mode 100644 index 7f98788..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/73/de/properties.index and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index deleted file mode 100644 index aea4be8..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.projects/exe_bsp/.indexes/properties.index and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index e2c27d6..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version deleted file mode 100644 index 6b2aaa7..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree deleted file mode 100644 index dfceb8e..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.root/3.tree and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources deleted file mode 100644 index 3ffe3ce..0000000 Binary files a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and /dev/null differ diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs deleted file mode 100644 index 8fd916c..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.altera.sbtgui.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -newSoftwareExampleWizardPage.defaultLocation=/home/alek/aktualne/vga/software/exe -newSoftwareExampleWizardPage.sopcinfoFile=/home/alek/aktualne/vga/vga_soc.sopcinfo -newSoftwareExampleWizardPage2.newBspLocation=/home/alek/aktualne/vga/software/exe_bsp diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs deleted file mode 100644 index 9c00dc4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.core.prj-exe_bsp.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -indexer/preferenceScope=0 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs deleted file mode 100644 index b8c9267..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.debug.core.cDebug.default_source_containers=\n\n\n\n\n\n\n\n diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index cf4f0fd..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -properties/exe.null.110175301/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.232835075=\#\n\#Fri Aug 16 16\:17\:39 CEST 2013\norg.eclipse.cdt.build.core.settings.holder.libs.1414464480\=\\\#\\n\\\#Sat Aug 10 12\\\:40\\\:43 CEST 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.915643465\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.2004193447\=\\\#\\n\\\#Sat Aug 10 12\\\:40\\\:43 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.c.linker.base.726713225\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.1948436996\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.852670760\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1086509423\=\\\#\\n\\\#Sat Aug 10 12\\\:40\\\:43 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.archiver.base.798587416\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.554916227\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1762448070\=\\\#\\n\\\#Sat Aug 10 12\\\:40\\\:43 CEST 2013\\nrebuildState\\\=true\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.232835075\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1154788565\=\\\#\\n\\\#Sat Aug 10 12\\\:40\\\:43 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.assembler.base.1611929987\=\\\#\\n\\\#Fri Aug 16 16\\\:17\\\:39 CEST 2013\\nrebuildState\\\=false\\n\n -properties/exe_bsp.null.593817795/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1865256075=\#\n\#Fri Aug 16 01\:13\:39 CEST 2013\norg.eclipse.cdt.build.core.settings.holder.libs.214780789\=\\\#\\n\\\#Sat Aug 10 12\\\:38\\\:03 CEST 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.1669324576\=\\\#\\n\\\#Sat Aug 10 12\\\:38\\\:03 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.1464081356\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.archiver.base.832006536\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.65641634\=\\\#\\n\\\#Sat Aug 10 12\\\:38\\\:03 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.1208364716\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.2011078959\=\\\#\\n\\\#Sat Aug 10 12\\\:38\\\:03 CEST 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.assembler.base.209941978\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.1981080678\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1865256075\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrcState\\\=0\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.1718703558\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\naltera.nios2.linux.gcc4.844397308\=\\\#\\n\\\#Fri Aug 16 01\\\:13\\\:39 CEST 2013\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1017439282\=\\\#\\n\\\#Sat Aug 10 12\\\:38\\\:03 CEST 2013\\nrebuildState\\\=true\\n\n diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs deleted file mode 100644 index 0451f54..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.cdt.ui.run.count.3_3_0=1 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs deleted file mode 100644 index cbfe61a..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs +++ /dev/null @@ -1,5 +0,0 @@ -content_assist_disabled_computers=org.eclipse.cdt.ui.parserProposalCategory\u0000org.eclipse.cdt.ui.textProposalCategory\u0000 -eclipse.preferences.version=1 -spelling_locale_initialized=true -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index a7fb09f..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -description.autobuilding=false -eclipse.preferences.version=1 -version=1 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs deleted file mode 100644 index 57e3b77..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug;org.eclipse.cdt.cdi.launch.localCLaunch,run -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.remoteApplicationLaunchType=org.eclipse.rse.remotecdt.dsf.debug,debug -eclipse.preferences.version=1 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs deleted file mode 100644 index a2917e5..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n -preferredTargets=org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget| diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs deleted file mode 100644 index 8e90a75..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.epp.usagedata.recording.last-upload=1376570884372 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs deleted file mode 100644 index 43e97e4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -mylyn.attention.migrated=true diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs deleted file mode 100644 index 8d462a6..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs deleted file mode 100644 index cec65c4..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.search.defaultPerspective=org.eclipse.search.defaultPerspective.none diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs deleted file mode 100644 index f9e585b..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -pref_first_startup=false diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs deleted file mode 100644 index 56cd496..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.team.ui.first_time=false diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs deleted file mode 100644 index 61f3bb8..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -overviewRuler_migration=migrated_3.1 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index a9b1d08..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,5 +0,0 @@ -PROBLEMS_FILTERS_MIGRATE=true -eclipse.preferences.version=1 -platformState=1376506471813 -quickStart=false -tipsAndTricks=true diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index 08076f2..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -showIntro=false diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs deleted file mode 100644 index 68b875a..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ /dev/null @@ -1,2 +0,0 @@ -ENABLED_DECORATORS=com.altera.sbtgui.project.decorator.bsp\:true,com.altera.sbtgui.project.nios2builddecorator\:true,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false, -eclipse.preferences.version=1 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch b/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch deleted file mode 100644 index b5760fb..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml deleted file mode 100644 index 4cba5ee..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- - - - - - -
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 795c14e..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv deleted file mode 100644 index ee2f5ea..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1376131036250 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1376131036252 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1376131036252 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376131036253 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1376131036254 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376131036254 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376131036255 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376131036256 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376131036257 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376131036258 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376131036259 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376131036262 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1376131036262 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1376131036263 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1376131036264 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1376131036264 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1376131036265 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1376131036266 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1376131036266 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1376131036267 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1376131036268 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1376131036268 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1376131036269 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1376131036270 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376131036271 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376131036272 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1376131036272 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1376131036273 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1376131036273 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1376131036274 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1376131036274 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1376131036275 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1376131036275 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1376131036276 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1376131036276 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1376131036277 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1376131036277 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1376131036278 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1376131036278 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1376131036279 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1376131036279 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376131036280 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1376131036281 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376131036281 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1376131036282 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1376131036282 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1376131036282 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1376131036283 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376131036284 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1376131036284 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376131036285 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376131036286 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376131036287 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1376131036287 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1376131036288 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376131036289 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376131036290 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1376131036291 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1376131036292 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1376131036293 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1376131036294 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1376131036295 -started,bundle,org.eclipse.ui.intro,3.4.100.v20110425,"org.eclipse.ui.intro",1376131036296 -started,bundle,org.eclipse.ui.intro.universal,3.2.500.v20110510,"org.eclipse.ui.intro.universal",1376131036296 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1376131036296 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376131036297 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1376131036297 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1376131036298 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1376131036299 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1376131036300 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1376131036301 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1376131036301 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1376131036302 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1376131036303 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376131036303 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376131036304 -started,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376131036305 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1376131036305 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1376131036306 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1376131036306 -os,sysinfo,,,"linux",1376131036310 -arch,sysinfo,,,"x86",1376131036310 -ws,sysinfo,,,"gtk",1376131036310 -locale,sysinfo,,,"en_US",1376131036310 -processors,sysinfo,,,"8",1376131036310 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1376131036310 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1376131036310 -java.specification.name,sysinfo,,,"Java Platform API Specification",1376131036310 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376131036310 -java.specification.version,sysinfo,,,"1.6",1376131036310 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1376131036310 -java.version,sysinfo,,,"1.6.0_23",1376131036310 -java.vm.info,sysinfo,,,"mixed mode",1376131036310 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1376131036310 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1376131036310 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376131036310 -java.vm.specification.version,sysinfo,,,"1.0",1376131036310 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1376131036310 -java.vm.version,sysinfo,,,"19.0-b09",1376131036310 -activated,view,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.internal.introview",1376131037084 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376131037092 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376131040229 -opened,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376131040352 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376131040469 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376131040473 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376131040474 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376131040475 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131040696 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376131080694 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1376131080745 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376131082775 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131086706 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1376131087599 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376131087604 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131091810 -started,bundle,org.eclipse.core.databinding,1.4.0.I20110111-0800,"org.eclipse.core.databinding",1376131097839 -started,bundle,org.eclipse.core.databinding.property,1.4.0.I20110222-0800,"org.eclipse.core.databinding.property",1376131097848 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1376131125720 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131125734 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131126061 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131126204 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131129383 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1376131131060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1376131137532 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131137545 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376131139449 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131144025 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376131145455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131145455 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131145463 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131149136 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376131150740 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131150747 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131150761 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131150816 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131152028 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131154455 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1376131155316 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131155316 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131155325 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131160626 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131164904 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131165241 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131165773 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131165855 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131165936 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376131166205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131188160 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376131191892 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131197467 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131223155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131226806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131230189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1376131231818 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131237296 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131243914 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131246868 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131247184 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131249367 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131250015 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131250639 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131251124 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131253584 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131256652 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131265640 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131265690 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376131265706 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131266463 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376131272942 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376131274813 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376131287937 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131301940 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376131305719 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376131305725 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131310237 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376131313002 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376131325056 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131367798 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376131368744 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376131368752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131390874 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131391387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131421435 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131436204 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131622941 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131627341 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131627812 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131663496 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131785831 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131800033 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376131916951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131929571 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131943836 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131968067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376131986811 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376131987388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376132007633 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132009153 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132018411 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132027625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132036015 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132038513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132048711 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132068384 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132069075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132071096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132530878 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132541348 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376132565658 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376132567511 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376132568454 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132589468 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132663139 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376132663956 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376133785066 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376133786020 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376133786921 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376133790145 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134140363 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134154914 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134462468 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134483615 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134497369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134515074 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134515988 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134516468 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134517075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134517792 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134538235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542002 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542168 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542329 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542800 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134542960 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134543145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134554793 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134575951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134578634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134578800 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134603520 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376134605081 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134605573 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134611791 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134618712 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134705125 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134705175 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134715979 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134718266 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134720847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134724128 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134726462 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134730658 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134773253 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376134789148 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134791599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376134792879 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134792890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376134792973 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134797271 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134800996 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376134802188 -opened,view,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.views.SearchView",1376134804483 -activated,view,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.views.SearchView",1376134804502 -executed,command,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.openFileSearchPage",1376134804652 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376134804672 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134816766 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376134857582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134882251 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376134961620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376135534024 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376135534639 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376135535741 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376135537342 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv deleted file mode 100644 index 113c346..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv +++ /dev/null @@ -1,268 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376135564541 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376136936542 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376136938461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376136938625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376136939578 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376136966204 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376136967249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376136970468 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376136971354 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376137000512 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376137064937 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376140853513 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376140879279 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376141009418 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376141039823 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376141171446 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376141181475 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142145252 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142146478 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142225842 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376142233450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376142233949 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376142234234 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142296409 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142397428 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142398048 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142398598 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142399027 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142520829 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376142544232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376142546113 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376142555704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376142566235 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376142576081 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376149153727 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376149170986 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376152910210 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376152911892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376155718036 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376155718696 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376169556740 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376169558693 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376169585033 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376169586257 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376177332685 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376177334705 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376177335878 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376177335971 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1376177336296 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376177336296 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376177336297 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376177337298 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376177337298 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376177337298 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376177337298 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376177337298 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376177337298 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1376177337298 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376177337299 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376177337299 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1376177337300 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1376177337300 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376177337300 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1376177337302 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1376177337302 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376177337302 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376177337302 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376177337302 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1376177337303 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376177337303 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376177337303 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1376177337305 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376177337305 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1376177337306 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376177337306 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1376177337307 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376177337307 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376177337307 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376177337307 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376177337307 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376177337307 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.13.0.132,"com.altera.sbtgui.flash.plugin",1376177337307 -stopped,bundle,com.altera.sbtgui.gprof,13.13.0.132,"com.altera.sbtgui.gprof",1376177337308 -stopped,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376177337308 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376177337308 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376177337308 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376177337308 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376177337309 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1376177337309 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1376177337310 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1376177337310 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1376177337311 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1376177337311 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376177337313 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1376177337314 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376177337314 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376177337314 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376177337314 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376177337314 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1376177337315 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1376177337315 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1376177337316 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376177337316 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1376177337317 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1376177337317 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376177337317 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376177337317 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376177337317 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376177337317 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1376177337318 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1376177337318 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376177337320 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1376177337321 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1376177337322 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1376177337322 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1376177337323 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1376177337323 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1376506478557 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1376506478558 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1376506478559 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376506478559 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1376506478559 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376506478559 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376506478559 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376506478559 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376506478559 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376506478559 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376506478559 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376506478559 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376506478559 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376506478559 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1376506478559 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1376506478560 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1376506478560 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1376506478560 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1376506478560 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1376506478560 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1376506478560 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1376506478561 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1376506478561 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1376506478561 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1376506478561 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1376506478561 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1376506478561 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1376506478561 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376506478561 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376506478561 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1376506478561 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1376506478561 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1376506478561 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1376506478562 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1376506478562 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1376506478562 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1376506478562 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1376506478562 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1376506478562 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1376506478562 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1376506478562 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1376506478563 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1376506478563 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1376506478563 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376506478563 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1376506478563 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376506478563 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1376506478563 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376506478563 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1376506478563 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1376506478563 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1376506478564 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1376506478564 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376506478564 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1376506478564 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376506478564 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376506478564 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376506478564 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1376506478564 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1376506478564 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376506478564 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376506478564 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1376506478564 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1376506478564 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1376506478564 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1376506478564 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1376506478564 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1376506478564 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376506478564 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1376506478564 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1376506478565 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1376506478565 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1376506478565 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1376506478565 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1376506478565 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1376506478565 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1376506478565 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376506478565 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376506478565 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1376506478565 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1376506478565 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1376506478566 -os,sysinfo,,,"linux",1376506478568 -arch,sysinfo,,,"x86",1376506478568 -ws,sysinfo,,,"gtk",1376506478568 -locale,sysinfo,,,"en_US",1376506478568 -processors,sysinfo,,,"8",1376506478568 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1376506478569 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1376506478569 -java.specification.name,sysinfo,,,"Java Platform API Specification",1376506478569 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376506478569 -java.specification.version,sysinfo,,,"1.6",1376506478569 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1376506478569 -java.version,sysinfo,,,"1.6.0_23",1376506478569 -java.vm.info,sysinfo,,,"mixed mode",1376506478569 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1376506478569 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1376506478569 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376506478569 -java.vm.specification.version,sysinfo,,,"1.0",1376506478569 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1376506478569 -java.vm.version,sysinfo,,,"19.0-b09",1376506478569 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1376506479308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506497903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498082 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498602 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506498946 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506499129 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506511970 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506512137 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376506513507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506513512 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506519323 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506519489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506519641 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506519794 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506519946 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506520089 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506520234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506520393 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376506520721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506521015 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376506522677 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376506523890 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376506523890 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506524666 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506526826 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376506529553 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376506529883 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376506534552 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376506534552 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376506534552 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506534599 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506537382 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506542059 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506546264 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506549097 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506549382 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506551277 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376506551447 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506551479 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376506557398 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376506557442 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376506566341 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506570776 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506573775 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376506575195 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506576632 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv deleted file mode 100644 index ce209f9..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv +++ /dev/null @@ -1,251 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506577292 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506577587 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506578336 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376506578717 -error,log,,,"Unable to validate connection settings.",1376506585318 -error,log,,,"Unable to validate connection settings.",1376506585319 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506585372 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506589438 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376506593905 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506594007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506625174 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376506625690 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376506625696 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376506626752 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506647648 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506649077 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506649714 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506650383 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506651610 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506652066 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506653065 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506655049 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376506663459 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376506664872 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506667968 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506668618 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506678967 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376506686941 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506689291 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376506694363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506700705 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376506704414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506712673 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506738642 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506747380 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506749340 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506961441 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376506964910 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506969399 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376506972095 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506973421 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376506973754 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376506976091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376506978545 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507013633 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507022684 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507024319 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507026599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507032366 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507050054 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507050107 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507065596 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507067471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507072101 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507075238 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507077930 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507079763 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507083576 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507118230 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507125581 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507153468 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507162518 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507167500 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507168153 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507171849 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507181465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507195955 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507200894 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507212491 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507214607 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507225075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507235548 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507237005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507240974 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507241136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507241396 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507246374 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507246867 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507247077 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507293497 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507343154 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507347808 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507374930 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507375944 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507382826 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507383521 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507383704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507385413 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507385539 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507388099 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507394410 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507403402 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507407712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507413723 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507418101 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507435641 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507436960 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507440371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507440882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507442877 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507443050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507444993 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507449556 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507505019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507508170 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507510757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507510923 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507511083 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507511211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507511387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507511555 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507511947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507520153 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507524407 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507530667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507540345 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507548703 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507564626 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507567770 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507569308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507571285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507572266 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507575769 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507576264 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507576455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507653407 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507657941 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507666506 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507670909 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507689381 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507689610 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507689834 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690494 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690573 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690613 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690654 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690695 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690775 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690814 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690855 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690895 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507690935 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507691145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507691346 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507691529 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507691705 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507691889 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507692089 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507692633 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507701298 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507710962 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507713471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507722639 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507725655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507727054 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507727501 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507730353 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376507734698 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507739348 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507739645 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507742772 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507762598 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507789645 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376507798622 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507803605 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507812320 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507815073 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507818862 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507825601 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507834315 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507860071 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507866943 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376507868542 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507869396 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507870801 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507890128 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376507908272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376507982390 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507984458 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507988699 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376507992941 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376507994680 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376507997960 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376508007363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376508046517 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376508058507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376508068653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376508069227 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376508071076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376508072819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376508075039 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376508078905 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376508083637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376508161269 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376508164969 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376508178406 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376508182725 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376508267383 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376511242835 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376511252310 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376514379563 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376514379925 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376514380627 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376514381003 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376570884366 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1376570884371 -error,log,,,"Unhandled event loop exception",1376570884487 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376570884894 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376597164832 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376597164906 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376597166618 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376597166671 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1376597166845 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376597166846 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376597166846 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376597167847 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376597167847 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376597167848 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376597167848 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376597167848 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376597167848 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1376597167848 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376597167848 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376597167848 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1376597167848 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1376597167848 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376597167848 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1376597167848 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1376597167848 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376597167848 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376597167848 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376597167849 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1376597167849 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376597167849 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376597167849 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1376597167849 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376597167849 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1376597167850 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376597167850 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1376597167850 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376597167850 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376597167850 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376597167850 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376597167850 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376597167851 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.13.0.132,"com.altera.sbtgui.flash.plugin",1376597167851 -stopped,bundle,com.altera.sbtgui.gprof,13.13.0.132,"com.altera.sbtgui.gprof",1376597167851 -stopped,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376597167851 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv deleted file mode 100644 index c9961d3..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv +++ /dev/null @@ -1,249 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376597167852 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376597167852 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376597167852 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376597167853 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1376597167853 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1376597167853 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1376597167853 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1376597167853 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1376597167853 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376597167857 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1376597167857 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376597167857 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376597167857 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376597167857 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1376597167857 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1376597167857 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376597167857 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376597167858 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376597167858 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376597167858 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1376597167858 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1376597167858 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376597167860 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1376597167860 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1376597167861 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1376597167861 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.files.ssh,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.ssh",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.shells.ssh,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.ssh",1376597167861 -stopped,bundle,org.eclipse.rse.subsystems.terminals.ssh,1.0.100.v201101042155,"org.eclipse.rse.subsystems.terminals.ssh",1376597167861 -stopped,bundle,org.eclipse.rse.connectorservice.ssh,2.1.200.v201101042155,"org.eclipse.rse.connectorservice.ssh",1376597167861 -stopped,bundle,org.eclipse.rse.connectorservice.telnet,1.2.200.v201101042155,"org.eclipse.rse.connectorservice.telnet",1376597167862 -stopped,bundle,org.eclipse.rse.dstore.security,3.0.300.v201103141607,"org.eclipse.rse.dstore.security",1376597167862 -stopped,bundle,org.eclipse.rse.efs,2.1.300.v201101042155,"org.eclipse.rse.efs",1376597167862 -stopped,bundle,org.eclipse.rse.subsystems.files.ftp,2.1.301.R33x_v201107212114,"org.eclipse.rse.subsystems.files.ftp",1376597167862 -stopped,bundle,org.eclipse.rse.subsystems.shells.core,3.1.201.R33x_v201106281309,"org.eclipse.rse.subsystems.shells.core",1376597167862 -stopped,bundle,org.eclipse.rse.subsystems.files.core,3.2.101.R33x_v201107181530,"org.eclipse.rse.subsystems.files.core",1376597167862 -stopped,bundle,org.eclipse.rse.subsystems.processes.shell.linux,1.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.shell.linux",1376597167862 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1376608298016 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1376608298017 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1376608298018 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376608298018 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376608298018 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1376608298019 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376608298019 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1376608298019 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376608298020 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1376608298020 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1376608298020 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1376608298021 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1376608298021 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1376608298022 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1376608298022 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1376608298022 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1376608298022 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1376608298023 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1376608298023 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1376608298023 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1376608298024 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1376608298024 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1376608298024 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1376608298024 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1376608298025 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1376608298025 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1376608298026 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1376608298026 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1376608298027 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1376608298027 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1376608298028 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1376608298028 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1376608298029 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1376608298029 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1376608298029 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1376608298030 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1376608298030 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1376608298031 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1376608298031 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1376608298031 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1376608298032 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1376608298032 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1376608298032 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1376608298033 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1376608298034 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1376608298034 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1376608298035 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1376608298035 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1376608298036 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1376608298036 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1376608298036 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1376608298036 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1376608298037 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1376608298037 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1376608298038 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1376608298038 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1376608298039 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1376608298039 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1376608298039 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1376608298040 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1376608298040 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1376608298041 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1376608298042 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1376608298042 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1376608298043 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1376608298043 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1376608298043 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1376608298044 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1376608298045 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1376608298045 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1376608298045 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1376608298046 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1376608298046 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1376608298047 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1376608298047 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1376608298048 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1376608298049 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1376608298049 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1376608298050 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376608298050 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376608298050 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1376608298050 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1376608298051 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1376608298051 -os,sysinfo,,,"linux",1376608298053 -arch,sysinfo,,,"x86",1376608298053 -ws,sysinfo,,,"gtk",1376608298053 -locale,sysinfo,,,"en_US",1376608298053 -processors,sysinfo,,,"8",1376608298053 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1376608298053 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1376608298053 -java.specification.name,sysinfo,,,"Java Platform API Specification",1376608298053 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376608298053 -java.specification.version,sysinfo,,,"1.6",1376608298053 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1376608298053 -java.version,sysinfo,,,"1.6.0_23",1376608298053 -java.vm.info,sysinfo,,,"mixed mode",1376608298053 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1376608298053 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1376608298053 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1376608298053 -java.vm.specification.version,sysinfo,,,"1.0",1376608298053 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1376608298053 -java.vm.version,sysinfo,,,"19.0-b09",1376608298053 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1376608298407 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608332316 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608409186 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1376608412802 -started,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1376608412803 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376608419121 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376608419121 -error,log,,,"Unable to validate connection settings.",1376608425004 -error,log,,,"Unable to validate connection settings.",1376608425006 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608425073 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608425137 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608426954 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608427092 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376608427884 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376608430744 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608430851 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608461204 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608464066 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608487272 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608490026 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608497159 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376608497674 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376608497689 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376608497690 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376608497690 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376608497707 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376608498714 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376608599981 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376608610845 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376608611029 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376608617405 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376608635846 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376608642972 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376608648147 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608747892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608749918 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376608767639 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376609664449 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376609665012 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376610176933 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376610177551 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376610184955 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376610187397 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376611308775 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611314564 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376611350211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376611351578 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611356691 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611375339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611377365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611379140 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611380898 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611388231 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611506323 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611506474 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611506721 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611512021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1376611525682 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1376611526289 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1376611526645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611530896 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611535413 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611586176 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611591146 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611608301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611608854 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611616991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611662881 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611667514 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611691729 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376611691873 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611692418 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611696734 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376611722247 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376611723267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611731753 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611738197 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376611754327 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376611756030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611773137 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611782006 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.select.lineEnd",1376611812823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376611813206 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376611813922 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376611823042 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376611832027 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376611957806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376633663069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1376633684794 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376633696088 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376633701717 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376633702777 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376633713067 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376633717879 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376633756292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376633766542 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376633773478 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv deleted file mode 100644 index b7a1387..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633780560 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633781005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633781173 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633783589 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633783764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633783908 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633784060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633784220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633784372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633784532 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376633788196 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376633809342 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376633939465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376633943674 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376633946759 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633987541 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376633987757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634001397 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634014545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634015047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634017820 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634018035 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634018267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634029235 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634055966 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634066291 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634070009 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634071820 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634075402 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634075570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634075721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634083445 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634106963 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634111753 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634129499 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634142512 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634144474 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634188984 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634193496 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634194413 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634197539 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634224210 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634231505 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634237250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634241720 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634242357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634304842 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634319975 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634325732 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634335898 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634370221 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634373079 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634375752 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634383477 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634388758 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634391549 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634403165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634409016 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634444589 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634454089 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634462465 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634463782 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634475890 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634478208 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634478792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634489142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634492549 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634495752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634499350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634503180 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634545043 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634546977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634556104 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634575992 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634576552 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634577023 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634581818 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634587583 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634622655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634622799 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634624637 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634655525 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634671425 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376634678853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376634681005 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376634684670 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634695031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634695182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634696120 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634697705 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634704836 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634715029 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634720075 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634726925 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376634728421 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376634728797 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634766025 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634786291 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376634804352 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634876203 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634895966 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634900792 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634904848 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634909066 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376634999492 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635023294 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635265706 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635266944 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635267758 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635274587 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635291251 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635296150 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635309031 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635313458 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635320831 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635325573 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635329564 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635332547 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635341341 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635422905 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635517543 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376635526543 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376635529437 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635551972 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635553027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635560172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635607953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376635623438 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376635624333 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635627013 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635642504 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635645830 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376635651503 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635656864 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635658395 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635660890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376635725270 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376635728250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376635738735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635758601 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376635766485 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635780887 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635783107 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635793473 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376635798150 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376635815812 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376635820903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635821838 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376635826222 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635830997 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635849824 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376635858174 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635910966 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635914828 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376635915965 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636287172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376636297730 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636299259 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636299862 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636300250 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636642446 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376636731359 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636732832 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636842339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376636853182 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376636854881 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637558973 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637588823 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637593331 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637597095 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637600583 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637602760 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637605852 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637608813 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637615769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376637624065 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637625933 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637626581 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637628457 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637629010 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637633755 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637641393 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376637645779 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376637656678 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638876551 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638885218 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638886098 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638886454 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638887201 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376638887782 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376639503390 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376639520227 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376639526420 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642674496 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376642691558 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376642696417 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376642701902 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376642715503 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376642718577 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1376642718781 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642720257 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642720566 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642724166 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642726163 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642727099 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642727724 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642729140 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642730668 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376642731436 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643011283 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643026327 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643027946 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643028450 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643029277 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643029926 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643030620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643032702 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643045085 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376643050320 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376643074305 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376643079792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643082184 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643082653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643082829 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643082989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643085441 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643086837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643089858 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643090591 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376643090956 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376643095013 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643104425 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643104597 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643105213 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376643105356 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376643105727 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376643109830 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376643121579 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376643128177 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647406030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376647409760 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376647409895 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376647410198 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647411882 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647420454 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376647424762 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376647442124 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376647476290 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647565264 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647798124 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647821511 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647847996 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376647857571 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376647859989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376647873299 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376647876587 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647878380 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647878731 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376647881471 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647954784 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647955463 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376647956085 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648141937 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376648147754 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648232255 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648232941 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648233756 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648248678 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376648254060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376648261530 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376648268795 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648332549 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648336412 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376648343704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376648348640 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv deleted file mode 100644 index 75b8550..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376648349743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376648352996 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376648358045 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376648447416 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376648451868 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376648480977 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376649801381 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376649806851 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376649846207 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650127430 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650131211 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650145156 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650459038 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650463101 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650499725 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650602259 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650649024 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650668059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650688184 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650689235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650695546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650696329 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650696921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650699143 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650714919 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650774619 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650795802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650830235 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650832770 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650845407 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650887510 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650888715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650889371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650889827 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650898673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650899816 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650901040 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376650901792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650924190 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650925163 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650929718 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650930875 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650933710 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650934739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650941382 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650943717 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650946713 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376650958422 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376650959878 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376650964504 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650975712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376650979840 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650981988 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376650986077 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376650991543 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651021086 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651022708 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651063369 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651067357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651068539 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651079320 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651079487 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651080991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651081142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651081295 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651082184 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651084790 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651087215 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651089750 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651092167 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376651100620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651125534 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651125984 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651126883 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651195799 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651204768 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651212948 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651215571 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651217670 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651221356 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651235620 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651238947 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376651259131 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651293660 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651294737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651296183 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651316067 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651332126 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651338786 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376651342739 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.select.lineEnd",1376651449491 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651449866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651450369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651452747 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651454989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651462885 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651463044 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651463188 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651463340 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651466021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651466877 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376651471405 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651503844 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651624752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651640124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651642021 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651646449 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651659234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651661885 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651729384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651731188 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651731853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651732260 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651735220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651735386 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651735554 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651736560 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651755513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651763673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651772320 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651775119 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376651778250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651779055 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.selectAll",1376651779057 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651781773 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651784339 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651787143 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651787697 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651788168 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651824528 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651831724 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651842882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651843033 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651861130 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651861305 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651861465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651861625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651861793 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651862450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651862673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376651862841 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376651871176 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651888519 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376651891195 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376651906334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376651993999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376651995325 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376652000313 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376652008608 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652017568 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652019976 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376652028314 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376652049999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652052448 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652657842 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652671997 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652680953 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652683299 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652690176 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376652701043 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653029903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653049743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653091727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376653096479 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376653098013 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376653101408 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376653101608 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653107510 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376653110455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376653110674 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653110680 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653114334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653125721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653153551 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653157429 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653157917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653168695 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653176917 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653315485 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653317374 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653548427 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376653560448 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653579837 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653607798 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653614780 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653620664 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653656901 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1376653670582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376653679798 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376653689018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653689534 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653695041 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653707987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376653718459 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376653721703 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653722003 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376653726018 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653728005 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653728203 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376653736963 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653742241 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376653744259 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653745778 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653745977 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376653756706 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653774492 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653774675 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653791021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653795207 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653796990 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653797285 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1376653798711 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653800175 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653800508 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653801069 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653801775 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1376653802358 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653806867 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653826222 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376653912971 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376653927852 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653928926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376653946498 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376653950376 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376653955101 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653962027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653963449 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376653995197 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376653995753 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654011625 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654012151 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654015038 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654207634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376654221936 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376654225373 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654227249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654230234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654230410 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654230553 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654232834 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654233671 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654235849 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654257042 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654257629 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654261187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376654265080 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654273317 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654276991 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376654284617 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654326446 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654326995 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654327375 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654328121 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654328977 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654329435 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654330296 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654331204 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654332692 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654337888 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376654355079 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376654356330 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654358344 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376654358944 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654359994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376654361682 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654364440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376654367394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376654370494 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654372587 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654374304 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654376451 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654380952 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376654386629 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376654409762 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376654413638 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv deleted file mode 100644 index 7f64738..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv +++ /dev/null @@ -1,251 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376654419155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654425594 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654427768 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654437866 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654457103 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376654463351 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654463415 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654931832 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654937060 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654937563 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654938353 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654947049 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654948858 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654956571 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376654957341 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655575096 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655575936 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655577169 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655578195 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655648765 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376655660039 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655666666 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.goto.wordNext",1376655667860 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376655693862 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376655703150 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376655707047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655709447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655709615 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655709768 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655717569 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376655722150 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655743474 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655744935 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655747260 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376655756662 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376655771645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376655773531 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655785513 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655788638 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655791561 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376655798887 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655806161 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655806802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655808555 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655810647 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376655819804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376655833917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376655835018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655841166 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655843022 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376655845926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655847197 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376655866125 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655870686 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655873220 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376655883026 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376655939195 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376656407823 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376656434267 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376656889968 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376656912813 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376656913747 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376656923029 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376656925436 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657061694 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657067494 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657069043 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657073750 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376657078380 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376657093636 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376657095207 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657095907 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657100107 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657102553 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376657111083 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376657170220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376657171384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657175301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376657177446 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376657178909 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376657180605 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657181579 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657185141 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657187287 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376657194586 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376657239277 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1376657242529 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376657245400 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657251241 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657254299 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657257814 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376657263367 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657281125 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657890169 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376657895019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657896600 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657905163 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657909119 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376657915315 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657931667 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376657938038 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376657973414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376657975156 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376657979858 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658014110 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658019626 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658020272 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658025211 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658029373 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658041679 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658083735 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658136766 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658140057 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658140247 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658141591 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658150703 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658176021 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658198991 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658208386 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658354890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658366199 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658374988 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376658385155 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658386265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658396189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658398518 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658400188 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658401645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658403084 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658403618 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658408524 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376658424091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658426384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658432589 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658434372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658435861 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658437733 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658438336 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376658442851 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658443354 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658444565 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658447763 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658482394 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658486970 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658498844 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658503279 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658512148 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658512531 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658512959 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658528203 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658529032 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658530036 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658540056 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658542511 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658552109 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658553870 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658577558 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658579508 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658602400 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658604860 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658605449 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658607097 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658611195 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658668070 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658670985 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376658682263 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658691673 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658741112 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658749006 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376658755941 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376658756179 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658756866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658761712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658769333 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658773581 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658774930 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658779839 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658899470 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658903205 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658914841 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658949953 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658954646 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376658960255 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376658967111 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658969989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376658975724 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658988584 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376658993903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376658995699 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376658996017 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659006296 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659009890 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659012198 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659024230 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659064257 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659069329 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659071609 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659082201 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659114394 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659142489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659170510 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659172100 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659176919 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659183966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659185155 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659186864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659187071 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659190160 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659190335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659191504 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.delete.line",1376659191535 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1376659192307 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659199030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659222870 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659224227 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659226464 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659231889 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659235946 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659268029 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659270548 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659273918 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659286615 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287274 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287314 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287355 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287474 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287514 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287554 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287674 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287835 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287875 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287915 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287955 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659287995 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288035 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288075 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288115 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288155 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288195 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288275 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288315 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288355 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv deleted file mode 100644 index c6f2249..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288395 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288435 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288555 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288675 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659288990 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659289198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659294439 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659299735 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659315154 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659357974 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659443084 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659446089 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659449447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659456566 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457226 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457266 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457305 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457345 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457385 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457425 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457505 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457665 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457705 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457746 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457786 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457826 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457907 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659457987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458107 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458227 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458307 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458427 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458467 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458547 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458587 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458627 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458773 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659458933 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659459085 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659459237 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659460988 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659464318 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659499388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659501543 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659509414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659509573 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659511845 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659518013 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.select.lineEnd",1376659535700 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659536107 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659537271 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659540462 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659545928 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659562932 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376659567048 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659576812 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659673736 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659686942 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659687631 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659688723 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659694202 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659703788 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659706967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659709340 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659710615 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659712916 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659714112 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659779421 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659790664 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376659948701 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659959864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659964764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659969154 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659969322 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376659969506 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659970376 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1376659974415 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376659977061 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659977834 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376659990930 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376659998248 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660000700 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660003514 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660007458 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660007634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660007802 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660008314 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660009705 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660016551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660020915 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660021065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660021225 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660021385 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660021537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660021697 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660023201 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660023361 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660023521 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660023681 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660024009 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660032715 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660062425 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660064122 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660066434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660069881 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660070065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660070489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660081521 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660081689 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660095346 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660095545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660098911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660114688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660115790 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660131823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660132909 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660135593 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660137057 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660148018 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660175292 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660189633 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660197823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660198732 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660200521 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660228887 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660230467 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660233671 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660238326 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660265170 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660275141 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660294270 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660295011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660300944 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660312626 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660318847 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660328572 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660340515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660345046 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660345867 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660352726 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660353916 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660357825 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660362524 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660372446 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660401144 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660402158 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660406535 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660416595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660417865 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660424030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376660424710 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660424718 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660430755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660434285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376660434572 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660434579 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660438308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660446533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1376660446839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660446847 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660455866 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660466332 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660467103 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660471596 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660477821 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660481165 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660493961 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660501557 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660515544 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660517026 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660548175 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660552511 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660587004 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660593687 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376660597973 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376660598164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660602655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660603695 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660605249 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660607469 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660616582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660621966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660628622 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660629582 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376660634365 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660658979 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660683593 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660684618 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660685850 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660696142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660697483 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660699822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660701363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660716115 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660718661 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660732840 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660739447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660743850 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660776603 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660782017 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660901849 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660909346 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660915137 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376660918893 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376660919217 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660928682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660929182 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660930166 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660930855 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660931284 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660937173 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660939514 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660941482 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660951052 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660962333 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660965195 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660968873 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376660976236 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376660982073 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376660984741 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376660990739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376660991410 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661001276 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661004020 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661016263 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661068512 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661077910 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661106867 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661111920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661172792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661174470 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661188931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661198442 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661204136 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661214383 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661214913 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661215624 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661241043 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661258680 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661259591 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661260572 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661424950 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661428757 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661429486 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661452550 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661454356 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661456576 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661456895 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661457391 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661467491 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661474783 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661477418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661484546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661488878 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661491076 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv b/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv deleted file mode 100644 index b64f2c2..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv +++ /dev/null @@ -1,162 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661495472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661501326 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661503005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661505769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661515062 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661519759 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661524469 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661528254 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661573189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661573996 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661585614 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661590317 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661605917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661606533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661609964 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661621560 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376661621735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661651871 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661656295 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661660620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661676899 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661706008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661718435 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661719013 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661720059 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661724967 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661730412 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661734618 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661735155 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661735667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661736318 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661741887 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661744818 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661837560 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661838191 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661840418 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661849845 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661860008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661861782 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661863218 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661867139 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376661871654 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661896859 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661898920 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661952198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661960265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661961550 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661966699 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376661977283 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376661980119 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376661984230 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376661987053 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376661990015 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662008893 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662015949 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662019268 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662021288 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662048351 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662055169 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662055965 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662059375 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662074332 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662102266 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662115141 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376662119059 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662157215 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662158920 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662160647 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662194585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662206069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662207173 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662212394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662226075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662227989 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662229069 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662229758 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662230528 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662232303 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662344140 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376662356960 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662359572 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376662362048 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662362652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662368169 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376662374936 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662375571 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662381385 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662382745 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662384716 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662394168 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376662398136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662399429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662405418 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376662409535 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662444746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662456770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662473416 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662474727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376662477290 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662479039 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662481578 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662553691 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1376662565175 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1376662567655 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1376662572557 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376662575546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1376662576024 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662580751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1376662646263 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662650954 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376662654251 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --stop, --accept-bad-sysid, --sidp=Not Found] return code: 8",1376662660202 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376664770910 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1376664781548 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376664781560 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376664804176 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376678855840 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376678857603 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376678861451 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376678862938 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680185589 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680186519 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680235534 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680237841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680406970 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376680407747 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376681848928 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376681849400 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376683150209 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376683151179 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376691694800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376691695445 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376691867941 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376691869334 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376693916489 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376693917384 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1376693918458 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1376693918503 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1376693918741 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1376693918742 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1376693918742 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1376693919743 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1376693919744 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1376693919744 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1376693919744 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1376693919744 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1376693919744 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1376693919744 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1376693919744 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1376693919744 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1376693919748 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1376693919749 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1376693919749 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1376693919757 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1376693919758 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1376693919758 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1376693919758 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1376693919758 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1376693919759 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1376693919760 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1376693919760 diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.history b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.history deleted file mode 100644 index cdb0987..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.history +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.index b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.index deleted file mode 100644 index f4d38f7..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/8/32/refactorings.index +++ /dev/null @@ -1,3 +0,0 @@ -1376131145414 Delete resource 'exe/readme.txt' -1376131150141 Delete resource 'exe/hello_world.c' -1376131155276 Delete resource 'exe/create-this-app' diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index 27eb404..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.search/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.search/dialog_settings.xml deleted file mode 100644 index 90a8182..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.search/dialog_settings.xml +++ /dev/null @@ -1,55 +0,0 @@ - -
-
- -
-
- - - - - -
-
- - - - - - - - - - - - - - -
-
- -
-
- - - - -
- -
-
- - - - - - - - - -
-
-
- -
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml deleted file mode 100644 index 2b2a156..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml +++ /dev/null @@ -1,27 +0,0 @@ - -
-
- - - - - -
-
- - - - - - - - - - - - - - - -
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 43dfc29..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,10 +0,0 @@ - -
-
- - - - - -
-
diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml deleted file mode 100644 index 7a16317..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +++ /dev/null @@ -1,465 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index fa6cab9..0000000 --- a/syn/components/vga/software/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/syn/components/vga/software/.metadata/version.ini b/syn/components/vga/software/.metadata/version.ini deleted file mode 100644 index c51ff74..0000000 --- a/syn/components/vga/software/.metadata/version.ini +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/syn/soc/firmware/.metadata/.lock b/syn/soc/firmware/.metadata/.lock deleted file mode 100644 index e69de29..0000000 diff --git a/syn/soc/firmware/.metadata/.log b/syn/soc/firmware/.metadata/.log deleted file mode 100644 index d168064..0000000 --- a/syn/soc/firmware/.metadata/.log +++ /dev/null @@ -1,894 +0,0 @@ -!SESSION 2013-11-02 21:27:04.222 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2013-11-02 21:27:06.504 -!MESSAGE FrameworkEvent ERROR -!STACK 0 -org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.p2.reconciler.dropins_1.1.100.v20110815-1419 [150]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.equinox.p2.touchpoint.eclipse; bundle-version="1.0.0" - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311) - at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389) - at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1131) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) - at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) - at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) - at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-02 21:30:06.504 -!MESSAGE Indexed 'exe_bsp' (77 sources, 55 headers) in 0.98 sec: 919 declarations; 2,181 references; 113 unresolved inclusions; 5 syntax errors; 193 unresolved names (5.86%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-02 21:30:07.971 -!MESSAGE Indexed 'exe' (1 sources, 13 headers) in 0.20 sec: 1 declarations; 1 references; 14 unresolved inclusions; 0 syntax errors; 0 unresolved names (0.00%) - -!ENTRY com.altera.sbtgui.launch 1 0 2013-11-02 22:09:45.881 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --stop --accept-bad-sysid] - -!ENTRY com.altera.sbtgui.launch 1 0 2013-11-02 22:09:47.084 -!MESSAGE Executing: [/bin/bash, -c, nios2-download '--cable=USB-Blaster on localhost [3-1.6]' --device=1 --instance=0 --go --accept-bad-sysid --reset-target /home/alek/aktualne/ao486/syn/soc/firmware/exe/exe.elf] - -!ENTRY com.altera.sbtgui.launch 4 0 2013-11-02 22:09:48.791 -!MESSAGE Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --go, --accept-bad-sysid, --reset-target, /home/alek/aktualne/ao486/syn/soc/firmware/exe/exe.elf] return code: 4, 'other error' - -!ENTRY com.altera.sbtgui.launch 4 0 2013-11-02 22:09:48.793 -!MESSAGE Downloading ELF Process failed -!SESSION 2013-11-05 23:36:52.505 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.osgi 2 0 2013-11-05 23:37:29.221 -!MESSAGE While loading class "org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot", thread "Thread[Worker-12,5,main]" timed out waiting (5002ms) for thread "Thread[main,6,main]" to finish starting bundle "org.eclipse.team.cvs.core_3.3.400.I20110510-0800 [273]". To avoid deadlock, thread "Thread[Worker-12,5,main]" is proceeding but "org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot" may not be fully initialized. -!STACK 0 -org.osgi.framework.BundleException: State change in progress for bundle "reference:file:plugins/org.eclipse.team.cvs.core_3.3.400.I20110510-0800.jar" by thread "main". - at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1087) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:297) - at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440) - at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:268) - at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107) - at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:463) - at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216) - at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400) - at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476) - at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) - at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) - at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) - at java.lang.ClassLoader.loadClass(Unknown Source) - at org.eclipse.team.internal.ccvs.core.util.BuildCleanupListener.resourceChanged(BuildCleanupListener.java:120) - at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:291) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285) - at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149) - at org.eclipse.core.internal.resources.Workspace.broadcastBuildEvent(Workspace.java:381) - at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:146) - at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) -Caused by: org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException - ... 22 more -Root exception: -org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException - at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1087) - at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:297) - at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440) - at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:268) - at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107) - at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:463) - at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216) - at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400) - at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476) - at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) - at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) - at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) - at java.lang.ClassLoader.loadClass(Unknown Source) - at org.eclipse.team.internal.ccvs.core.util.BuildCleanupListener.resourceChanged(BuildCleanupListener.java:120) - at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:291) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285) - at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149) - at org.eclipse.core.internal.resources.Workspace.broadcastBuildEvent(Workspace.java:381) - at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:146) - at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 18:44:56.580 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.43 sec: 1,672 declarations; 2,021 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 18:44:57.506 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.92 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 18:45:10.442 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.77 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 18:45:15.386 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.21 sec: 1,672 declarations; 2,021 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) -!SESSION 2013-11-06 19:21:22.063 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:22:52.177 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.54 sec: 1,672 declarations; 2,021 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:22:53.191 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.99 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:02.636 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.24 sec: 1,510 declarations; 33 references; 0 unresolved inclusions; 0 syntax errors; 2 unresolved names (0.13%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:03.306 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.67 sec: 4,724 declarations; 52 references; 1 unresolved inclusions; 2 syntax errors; 2 unresolved names (0.04%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:10.633 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.20 sec: 1,557 declarations; 197 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (2.45%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:11.215 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.58 sec: 4,897 declarations; 1,165 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.33%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:32.868 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.15 sec: 1,510 declarations; 33 references; 0 unresolved inclusions; 0 syntax errors; 2 unresolved names (0.13%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:33.360 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.49 sec: 4,724 declarations; 52 references; 1 unresolved inclusions; 2 syntax errors; 2 unresolved names (0.04%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:38.724 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.13 sec: 1,510 declarations; 33 references; 0 unresolved inclusions; 0 syntax errors; 2 unresolved names (0.13%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:39.129 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.40 sec: 4,724 declarations; 52 references; 1 unresolved inclusions; 2 syntax errors; 2 unresolved names (0.04%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:23:50.579 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.14 sec: 1,510 declarations; 33 references; 0 unresolved inclusions; 0 syntax errors; 2 unresolved names (0.13%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:24:45.268 -!MESSAGE Indexed 'exe' (1 sources, 58 headers) in 0.15 sec: 1,672 declarations; 2,021 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:24:45.692 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.42 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:32:35.369 -!MESSAGE Indexed 'exe' (1 sources, 60 headers) in 0.15 sec: 1,672 declarations; 2,023 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:32:35.844 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.47 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:32:44.102 -!MESSAGE Indexed 'exe_bsp' (78 sources, 175 headers) in 0.43 sec: 5,017 declarations; 5,873 references; 1 unresolved inclusions; 2 syntax errors; 20 unresolved names (0.18%) - -!ENTRY org.eclipse.cdt.core 1 0 2013-11-06 19:32:49.520 -!MESSAGE Indexed 'exe' (1 sources, 60 headers) in 0.14 sec: 1,672 declarations; 2,023 references; 0 unresolved inclusions; 0 syntax errors; 44 unresolved names (1.18%) - -!ENTRY org.eclipse.core.jobs 2 2 2013-11-06 19:36:41.609 -!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob$ProgressUpdateJob -!SESSION 2013-11-06 19:36:46.940 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2013-11-07 21:38:11.192 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more - -!ENTRY org.eclipse.jface 2 0 2013-11-18 21:07:20.582 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2013-11-18 21:07:20.582 -!MESSAGE A conflict occurred for ALT+ARROW_RIGHT: -Binding(ALT+ARROW_RIGHT, - ParameterizedCommand(Command(org.eclipse.cdt.ui.hover.forwardMacroExpansion,Forward, - Step forward in macro expansions, - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionExplorationControl$4@8b4f65, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) -Binding(ALT+ARROW_RIGHT, - ParameterizedCommand(Command(org.eclipse.ui.navigate.forwardHistory,Forward History, - Move forward in the editor navigation history, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - ActionHandler(org.eclipse.ui.internal.NavigationHistoryAction@98ad6), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -!SUBENTRY 1 org.eclipse.jface 2 0 2013-11-18 21:07:20.582 -!MESSAGE A conflict occurred for ALT+ARROW_LEFT: -Binding(ALT+ARROW_LEFT, - ParameterizedCommand(Command(org.eclipse.cdt.ui.hover.backwardMacroExpansion,Back, - Step backward in macro expansions, - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionExplorationControl$3@79fb1c, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) -Binding(ALT+ARROW_LEFT, - ParameterizedCommand(Command(org.eclipse.ui.navigate.backwardHistory,Backward History, - Move backward in the editor navigation history, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - ActionHandler(org.eclipse.ui.internal.NavigationHistoryAction@550a48), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) - -!ENTRY org.eclipse.jface 2 0 2013-11-18 21:07:30.043 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2013-11-18 21:07:30.043 -!MESSAGE A conflict occurred for F3: -Binding(F3, - ParameterizedCommand(Command(org.eclipse.cdt.ui.edit.opendecl,Open Declaration, - Open an editor on the selected element's declaration(s), - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - LegacyHandlerWrapper(ActionHandler(action=org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction@b4c725)), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.cEditorScope,,,system) -Binding(F3, - ParameterizedCommand(Command(org.eclipse.cdt.ui.edit.opendecl,Open Declaration, - Open an editor on the selected element's declaration(s), - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - LegacyHandlerWrapper(ActionHandler(action=org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction@b4c725)), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) -!SESSION 2013-11-30 23:42:28.205 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.core.resources 2 10035 2013-11-30 23:42:30.828 -!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. - -!ENTRY org.eclipse.ui 4 0 2013-11-30 23:42:36.196 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2013-12-01 21:27:17.543 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.core.resources 2 10035 2013-12-01 21:27:21.253 -!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. - -!ENTRY org.eclipse.jface 2 0 2013-12-01 22:01:33.105 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2013-12-01 22:01:33.105 -!MESSAGE A conflict occurred for ALT+ARROW_RIGHT: -Binding(ALT+ARROW_RIGHT, - ParameterizedCommand(Command(org.eclipse.cdt.ui.hover.forwardMacroExpansion,Forward, - Step forward in macro expansions, - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionExplorationControl$4@1318ddc, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) -Binding(ALT+ARROW_RIGHT, - ParameterizedCommand(Command(org.eclipse.ui.navigate.forwardHistory,Forward History, - Move forward in the editor navigation history, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - ActionHandler(org.eclipse.ui.internal.NavigationHistoryAction@5883d9), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -!SUBENTRY 1 org.eclipse.jface 2 0 2013-12-01 22:01:33.105 -!MESSAGE A conflict occurred for ALT+ARROW_LEFT: -Binding(ALT+ARROW_LEFT, - ParameterizedCommand(Command(org.eclipse.cdt.ui.hover.backwardMacroExpansion,Back, - Step backward in macro expansions, - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionExplorationControl$3@1384f06, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) -Binding(ALT+ARROW_LEFT, - ParameterizedCommand(Command(org.eclipse.ui.navigate.backwardHistory,Backward History, - Move backward in the editor navigation history, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - ActionHandler(org.eclipse.ui.internal.NavigationHistoryAction@1cc4bf5), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) - -!ENTRY org.eclipse.jface 2 0 2013-12-01 22:01:33.113 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2013-12-01 22:01:33.113 -!MESSAGE A conflict occurred for F3: -Binding(F3, - ParameterizedCommand(Command(org.eclipse.cdt.ui.edit.opendecl,Open Declaration, - Open an editor on the selected element's declaration(s), - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - LegacyHandlerWrapper(ActionHandler(action=org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction@847678)), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.cEditorScope,,,system) -Binding(F3, - ParameterizedCommand(Command(org.eclipse.cdt.ui.edit.opendecl,Open Declaration, - Open an editor on the selected element's declaration(s), - Category(org.eclipse.cdt.ui.category.source,C/C++ Source,C/C++ Source Actions,true), - LegacyHandlerWrapper(ActionHandler(action=org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction@847678)), - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.cdt.ui.macroExpansionHoverScope,,,system) - -!ENTRY org.eclipse.ui 4 0 2013-12-07 18:31:42.589 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2013-12-23 23:26:33.773 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2013-12-23 23:26:43.111 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2013-12-27 02:57:54.736 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2013-12-29 22:14:21.217 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more - -!ENTRY org.eclipse.core.jobs 2 2 2013-12-31 00:15:43.732 -!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob$ProgressUpdateJob -!SESSION 2014-01-07 19:30:21.664 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2014-01-07 19:30:31.186 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2014-01-09 20:14:45.530 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.core.jobs 2 2 2014-01-12 01:45:22.391 -!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob$ProgressUpdateJob - -!ENTRY org.eclipse.core.jobs 2 2 2014-01-12 01:45:22.392 -!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob$ProgressUpdateJob -!SESSION 2014-01-15 20:29:46.145 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2014-01-15 20:29:54.300 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2014-01-17 23:39:30.199 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.core.resources 2 10035 2014-01-17 23:39:32.893 -!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. -!SESSION 2014-01-29 21:25:56.702 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.core.resources 2 10035 2014-01-29 21:26:04.792 -!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. - -!ENTRY org.eclipse.ui 4 0 2014-01-29 21:26:10.074 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more - -!ENTRY org.eclipse.core.jobs 2 2 2014-01-29 23:59:09.618 -!MESSAGE Job found still running after platform shutdown. Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.cdt.internal.core.pdom.PDOMIndexerJob$ProgressUpdateJob -!SESSION 2014-03-23 22:31:52.923 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2014-03-23 22:32:02.222 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more -!SESSION 2014-03-30 13:35:43.333 ----------------------------------------------- -eclipse.buildId=M20120208-0800 -java.version=1.6.0_23 -java.vendor=Sun Microsystems Inc. -BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US -Framework arguments: -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective -Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.cpp.product -perspective com.altera.sbtgui.ui.cPerspective - -!ENTRY org.eclipse.ui 4 0 2014-03-30 13:36:29.457 -!MESSAGE Unhandled event loop exception -!STACK 0 -org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]) - at org.eclipse.swt.SWT.error(SWT.java:4282) - at org.eclipse.swt.SWT.error(SWT.java:4197) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) - at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) - at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) - at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) - at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) - at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) - at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) - at org.eclipse.equinox.launcher.Main.run(Main.java:1410) - at org.eclipse.equinox.launcher.Main.main(Main.java:1386) -Caused by: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] - at org.eclipse.swt.SWT.error(SWT.java:4308) - at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) - at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) - at org.eclipse.swt.browser.Browser.(Browser.java:99) - at org.eclipse.epp.usagedata.internal.ui.wizards.TermsOfUseWizardPage.createControl(TermsOfUseWizardPage.java:48) - at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) - at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) - at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608) - at org.eclipse.jface.window.Window.create(Window.java:431) - at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) - at org.eclipse.jface.window.Window.open(Window.java:790) - at org.eclipse.epp.usagedata.internal.ui.uploaders.AskUserUploader$1.run(AskUserUploader.java:65) - at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164) - at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158) - at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) - at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) - ... 23 more diff --git a/syn/soc/firmware/.metadata/.mylyn/repositories.xml.zip b/syn/soc/firmware/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index a6d7844..0000000 Binary files a/syn/soc/firmware/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/.log b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/.log deleted file mode 100644 index 70ecd59..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/.log +++ /dev/null @@ -1,9 +0,0 @@ -*** SESSION Nov 02, 2013 21:27:53.98 ------------------------------------------- -*** SESSION Nov 05, 2013 23:37:22.33 ------------------------------------------- -*** SESSION Nov 06, 2013 19:21:25.94 ------------------------------------------- -*** SESSION Dec 01, 2013 21:27:22.69 ------------------------------------------- -*** SESSION Dec 23, 2013 23:26:39.29 ------------------------------------------- -*** SESSION Dec 27, 2013 02:58:00.26 ------------------------------------------- -*** SESSION Jan 07, 2014 19:30:27.32 ------------------------------------------- -*** SESSION Jan 09, 2014 20:14:50.24 ------------------------------------------- -*** SESSION Jan 29, 2014 21:26:06.21 ------------------------------------------- diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe.1383424207763.pdom b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe.1383424207763.pdom deleted file mode 100644 index 3db5d1b..0000000 Binary files a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe.1383424207763.pdom and /dev/null differ diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1383424205457.pdom b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1383424205457.pdom deleted file mode 100644 index 1a30768..0000000 Binary files a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/exe_bsp.1383424205457.pdom and /dev/null differ diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/shareddefaults.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/shareddefaults.xml deleted file mode 100644 index c4b91cf..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.core/shareddefaults.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/.log b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/.log deleted file mode 100644 index e69de29..0000000 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc deleted file mode 100644 index b1a110a..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe.sc +++ /dev/null @@ -1,792 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc deleted file mode 100644 index b9bc087..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/exe_bsp.sc +++ /dev/null @@ -1,792 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c deleted file mode 100644 index 8b13789..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp deleted file mode 100644 index 8b13789..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.ui/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.ui/dialog_settings.xml deleted file mode 100644 index 5ca0b77..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.make.ui/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml deleted file mode 100644 index 71c788d..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/dialog_settings.xml +++ /dev/null @@ -1,12 +0,0 @@ - -
- -
-
-
- - -
-
-
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log deleted file mode 100644 index abd900e..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe.build.log +++ /dev/null @@ -1,7 +0,0 @@ - -**** Clean-only build of configuration Nios II for project exe **** - -make clean -[exe clean complete] - -**** Build Finished **** diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log deleted file mode 100644 index f76cf65..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/exe_bsp.build.log +++ /dev/null @@ -1,7 +0,0 @@ - -**** Clean-only build of configuration Nios II for project exe_bsp **** - -make clean -[BSP clean complete] - -**** Build Finished **** diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log b/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log deleted file mode 100644 index 92c4cd7..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log +++ /dev/null @@ -1,14 +0,0 @@ - -**** Clean-only build of configuration Nios II for project exe **** - -make clean -[exe clean complete] - -**** Build Finished **** - -**** Clean-only build of configuration Nios II for project exe_bsp **** - -make clean -[BSP clean complete] - -**** Build Finished **** diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/1/d0ff5e22515500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/1/d0ff5e22515500131519a78646da4feb deleted file mode 100644 index f0d54e8..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/1/d0ff5e22515500131519a78646da4feb +++ /dev/null @@ -1,634 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector+=8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=64; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[17]; - uint8 padding[3]; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - } floppy; - struct end_of_list_t { - uint8 type; - uint8 name[15]; - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(true) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, ) - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[33]; - for(int i=0; i<32; i++) chars[i] = i; - chars[32] = 0; - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - bool zero_delay_last = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - - ptr[i] = read_byte(); - crc32(ptr + i, NULL); - if((i%1024) == 0) printf("%08x - %d%%\n", (unsigned int)(ptr+i), (i*100/size)); - } - - unsigned int recv_crc = read_int(); - unsigned int copy_crc = 0; - crc32(NULL, ©_crc); - - unsigned int local_crc = 0; - crc32(NULL, NULL); - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit... "); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) chars[i] = i+1; - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = 0; - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - } - - unsigned char in[8]; - - for(int i=0; i> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - for(int i=0; i<128; i++) { - IOWR(VGA_BASE, i, i); - } - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - char last_key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - } floppy; - struct end_of_list_t { - uint8 type; - uint8 name[15]; - uint32 crc32; - } end_of_list; - }; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[33]; - for(int i=0; i<32; i++) chars[i] = i; - chars[32] = 0; - - osd_print(0, false, chars); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > )) { - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(1*16+0, true, "SD reinit... "); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - uint32 index_start = 0; - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000101; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[33]; - for(int i=0; i<32; i++) chars[i] = i+1; - chars[32] = 0; - - osd_print(0, false, (const char *)chars); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit... "); - - while(sd_status == 0) { - - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) == 0) { - rd = IORD(JTAG_UART_BASE, 0); - if() rd &= 0xFF; - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/5/a02ca24e254700131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/5/a02ca24e254700131519a78646da4feb deleted file mode 100644 index 285b13b..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/5/a02ca24e254700131519a78646da4feb +++ /dev/null @@ -1,537 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_start = i; - break; - } - } - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } - - - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) { - rd &= 0xFF; - break; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit... "); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(DRIVER_SD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//"--Select BIOS:--" -//"Loading BIOS... " -int select_and_load_bios(const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, TYPE_BIOS); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, ); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char ptr unsigned char *crc_output) { - unsigned char crc[32]; - for(int i=0; i<32; i++) crc[i] = 1; - - unsigned char in[8]; - - for(int i=0; i> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, ); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = 0; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) chars[i] = i+1; - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - for(int i=65; i<128; i++) { - IOWR(VGA_BASE, i, i); - } - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=65; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - if(chars[i] == '\\') chars[i] = 'b'; - if(chars[i] == '@') chars[i] = 'a'; - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu() { - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - 512 * hd_spt, //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - unsigned char crc[32]; - for(int i=0; i<32; i++) crc[i] = 1; - - unsigned char in[8]; - - for(int i=0; i> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char ptr, unsigned char *crc_output) { - unsigned char crc[32]; - for(int i=0; i<32; i++) crc[i] = 1; - - unsigned char in[8]; - - for(int i=0; i> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//"--Select BIOS:--" -int select_and_load_bios(const char *select_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, TYPE_BIOS); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, "Loading BIOS... "); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char ptr, unsigned int *crc_output) { - unsigned char crc[32]; - for(int i=0; i<32; i++) crc[i] = 1; - - unsigned char in[8]; - - for(int i=0; i> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[17]; - uint8 padding[2]; - uint32 destination_sector; - uint32 size; - uint32 crc32; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[17]; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = false; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[33]; - for(int i=0; i<32; i++) chars[i] = i; - chars[32] = 0; - - osd_print(0, false, (const char *)chars); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) == 0) { - rd = IORD(JTAG_UART_BASE, 0); - if() rd &= 0xFF; - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/79/30a65462565500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/79/30a65462565500131519a78646da4feb deleted file mode 100644 index 20dd1b5..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/79/30a65462565500131519a78646da4feb +++ /dev/null @@ -1,679 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - while(sd_status == 0) { - osd_print(1*16+0, true, "SD reinit... "); - usleep(1000000); - - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(1*16+0, true, "SD reinit... "); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { ; } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { ; } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, ); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, 0, "ao486 SoC 1.0"); - - - - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) { - rd &= 0xFF; - break; - } - } - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0e983f7575500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0e983f7575500131519a78646da4feb deleted file mode 100644 index 416386b..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e0e983f7575500131519a78646da4feb +++ /dev/null @@ -1,684 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(true) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((key & 0x1) == 0) - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - // - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//"--Select BIOS:--" -//"Loading BIOS... " -int select_and_load_bios(const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, TYPE_BIOS); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - - for(int i=0; i<12; i++) { - - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { - uint32 key; - key = IORD(PIO_INPUT_BASE, 0); - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - while(sd_status == 0) { - osd_print(1*16+0, true, "SD reinit... "); - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - - printf("crc_val: %08x\n", crc_val); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - IOWR(SD_CARD_BASE, 0, 0); - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_jtag(); - rd |= read_jtag() << 8; - rd |= read_jtag() << 16; - rd |= read_jtag() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_jtag(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383US : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[17]; - uint8 padding[2]; - uint32 sector; - uint32 size; - uint32 crc32; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - if(chars[i] == '\\') chars[i] = 'b'; - if(chars[i] == '@') chars[i] = 'b'; - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 crc32; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_jtag(); - rd |= read_jtag() << 8; - rd |= read_jtag() << 16; - rd |= read_jtag() << 24; - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, ); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_jtag(); - rd |= read_jtag() << 8; - rd |= read_jtag() << 16; - rd |= read_jtag() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - } floppy; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - } end_of_list; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - - for(int i=-5; i<7; i++) { - - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit... "); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - if(chars[i] == '\\') chars[i] = 'b''' - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - // - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -int select_and_load_bios(uint8 type, const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, false, " "); - - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - if(chars[i] == '\\') chars[i] = 'b'; - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - usleep(100000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (()*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - } floppy; - struct end_of_list_t { - uint8 type; - uint8 name[15]; - uint32 crc32; - } end_of_list; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - - for(int i=0; i<12; i++) { - - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { ; } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, false, "ao486 SoC 1.0"); - - osd_print(2*16+1, false, "SD init..."); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(2*16+1, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(2*16+1, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(2*16+1, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(const char *select_txt) { - osd_print(3*16+0, false, "--Select BIOS:--"); - - int menu_result = show_menu(0xFF, TYPE_BIOS); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, "Loading BIOS... "); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_val = ~crc_val; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9*i)*16, invert, " "); - osd_print((9*i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { ; } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint8 type; - uint8 name[15]; - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - return -1; -} - -inline uint8 read_byte() { - while(true) { - unsigned int rd = IORD(JTAG_UART_BASE, 0); - if((rd >> 15) & 1) return rd & 0xFF; - } -} - -uint32 read_int() { - uint32 rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(uint8 *ptr, uint32 *crc_output) { - static uint8 crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - uint8 in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - uint8 new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct hdd_t { - uint32 sector; - uint32 cyliders; - uint32 heads; - uint32 spt; - } hdd; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_HDD 3 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -#define ENTRY_ABORT -500 - -int show_menu(uint8 mask, uint8 value, bool abortable) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - if(key == 'N' && abortable) return ENTRY_ABORT; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, - const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) -{ - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type, false); - if(menu_result < 0) return menu_result; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - -/* - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - return; - } - - if(key == 'N') return; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu_floppy() { - osd_print(16*1, false, "Floppy inserted"); - - int index = 9; - - bool zero_delay_last = true; - while(true) { - //draw contents - for(int i=16*2; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_print(16*index, false, "Eject floppy"); - osd_print(16*(index+1), false, floppy_writeprotect? "Clear writeprot" : "Set writeprotect"); - for(int i=0; i<16; i++) IOWR(VGA_BASE, 16*9+i, 0x100 | (IORD(VGA_BASE, 16*9+i) & 0xFF)); - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else if((keys & 0x8) == 0) key = 'N'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') { - if(index == 9) { //eject - floppy_index = -1; - - floppy_writeprotect = true; - - int floppy_media = - (floppy_index < 0)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_index >= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - } - if(index == 8) { //writeprotect - floppy_writeprotect = !floppy_writeprotect; - - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - } - - return; - } - - if(key == 'N') return; - - if(key == '^' && index == 8) index++; - if(key == 'v' && index == 9) index--; - - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -void runtime_menu() { - //clear osd - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } - - if(floppy_index < 0) runtime_menu_no_floppy(); - else runtime_menu_floppy(); - - osd_enable(false); - - //wait for key release - while((IORD(PIO_INPUT_BASE, 0) & 0xF) != 0xF) { ; } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - for(int i=0; i<134217728/4; i++) IOWR(SDRAM_BASE, i, 0); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i= 0? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = entries[hdd_index].args.hdd.cyliders; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = entries[hdd_index].args.hdd.heads; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = entries[hdd_index].args.hdd.spt; //1-255; 8 bits; - - int hdd_sd_base = entries[hdd_index].args.hdd.sector; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - - - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - osd_print(1*16+1, 0, "ao486 SoC 1.0"); - - - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 0) { - osd_print(1*16+0, true, "SD reinit... "); - usleep(1000000); - - sd_status = IORD(SD_CARD_BASE, 0); - } - - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - - } - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) { - rd &= 0xFF; - break; - } - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/db/70de319f5a5500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/db/70de319f5a5500131519a78646da4feb deleted file mode 100644 index fe9b4a6..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/db/70de319f5a5500131519a78646da4feb +++ /dev/null @@ -1,695 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - uint32 index_start = 0; - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - (unsigned short)hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - for(int i=0; i<128; i++) { - IOWR(VGA_BASE, i, i); - } - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 1); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 512)? 512 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector++; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - IOWR(SD_CARD_BASE, 0, entries); - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - if(chars[i] == '\\') chars[i] = 'b'; - if(chars[i] == '@') chars[i] = 'a'; - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - unsigned char chars[129]; - for(int i=0; i<128; i++) { - chars[i] = i+1; - if(chars[i] == '%') chars[i] = 'p'; - } - chars[128] = 0; - - osd_print(0, false, (const char *)chars); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=48; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - while(true) { ; } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - - - //check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - while(sd_status == 0) { - osd_print(1*16+0, true, "SD reinit... "); - usleep(1000000); - - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - if(sd_status != 2) { - osd_print(1*16+0, true, "SD failed: %d ", sd_status); - return 0; - } - osd_print(1*16+0, false, "SD OK "); - - while(true) { ; } - - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start + 1; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i >= index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(true) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - } - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - char last_key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - for(int i=0; i<) - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f3/10d2b3e5625500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f3/10d2b3e5625500131519a78646da4feb deleted file mode 100644 index 55ec042..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f3/10d2b3e5625500131519a78646da4feb +++ /dev/null @@ -1,818 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - int sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = read_byte(); - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void get_crc(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - crc_output = 0; - for(int i=0; i<32; i++) { - crc_output |= crc[i] << (31-i); - } - crc_output = ~crc_output; - crc_output[0] = crc_val; - crc_output[1] = crc_val >> 8; - crc_output[2] = crc_val >> 16; - crc_output[3] = crc_val >> 24; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = (ptr[i] >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); - - unsigned int crc_val = 0; - for(int i=0; i<32; i++) { - crc_val |= crc[i] << (i); - } - //printf("crc_val: %08x, %08x\n", crc_val, ~crc_val); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -int select_and_load_bios(const char *select_txt, const char *load_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, ); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*1, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*1, false, "Verifying BIOS.."); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f4/0096e36b625500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f4/0096e36b625500131519a78646da4feb deleted file mode 100644 index e4f81ca..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f4/0096e36b625500131519a78646da4feb +++ /dev/null @@ -1,820 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} -//TYPE_BIOS -//"--Select BIOS:--" -//"Loading BIOS... " -//"Verifying BIOS.." -//"BIOS vrfy failed" -//"BIOS verify OK " -int select_and_load_bios(uint8 type, uint32 position, const char *select_txt, const char *load_txt, const char *verify_txt, const char *verify_failed_txt, const char *verify_ok_txt) { - osd_print(3*16+0, false, select_txt); - - int menu_result = show_menu(0xFF, type); - if(menu_result < 0) return 0; - - for(int i=16; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - //load bios - osd_print(16*position, false, load_txt); - - uint8 *dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - uint32 size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - uint32 sector = entries[menu_result].args.bios.sector; - - uint8 sector_buf[4096]; - while(size_in_bytes > 0) { - IOWR(SD_CARD_BASE, 0, (int)sector_buf); //Avalon address base - IOWR(SD_CARD_BASE, 1, sector); //SD sector - IOWR(SD_CARD_BASE, 2, 8); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - uint32 current_size = (size_in_bytes > 4096)? 4096 : size_in_bytes; - memcpy(dst_ptr, sector_buf, current_size); - - dst_ptr += current_size; - size_in_bytes -= current_size; - sector += 8; - } - - osd_print(16*position, false, verify_txt); - - dst_ptr = (uint8 *)entries[menu_result].args.bios.destination; - size_in_bytes = entries[menu_result].args.bios.size_in_bytes; - - crc32(NULL, NULL); - for(uint32 i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned char cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20 : 0x00, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - bool zero_delay_last = true; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - bool zero_delay = true; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - - if(key == 0) zero_delay = false; - } - - if(key == 'Y') return index_start + index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - if(zero_delay_last && zero_delay) usleep(100000); - else usleep(300000); - - zero_delay_last = zero_delay; - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i> 15) & 1) rd &= 0xFF; - - } - - - //-------------------------------------------------------------------------- - - //release reset - IOWR(PIO_OUTPUT_BASE, 0, 0x00); - - - return 0; -} diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f6/503a9510405500131519a78646da4feb b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f6/503a9510405500131519a78646da4feb deleted file mode 100644 index 7ab01fe..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.resources/.history/f6/503a9510405500131519a78646da4feb +++ /dev/null @@ -1,617 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - int index = 0; - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -1; - } - -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) /* push current alignment to stack */ -#pragma pack(1) /* set alignment to 1 byte boundary */ - -#pragma pack(pop) /* restore original alignment from stack */ - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - - }; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -union entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -struct entry_t { - - uint8 type; - uint8 name[15]; - - union args_t { - struct bios_t { - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint32 sector; - } floppy; - struct end_of_list_t { - uint32 crc32; - } end_of_list; - } args; -}; - -#pragma pack(pop) - -#define ENTRIES_COUNT 128 - -struct entry_t entries[ENTRIES_COUNT]; - -#define TYPE_BIOS 1 -#define TYPE_VGABIOS 2 -#define TYPE_FD_1_44M 16 -#define TYPE_CRC32 127 - -int show_menu(uint8 mask, uint8 value) { - - int index_start = -1; - for(int i=0; i=0; i--) { - if((entries[i].type & mask) == value) { - index_end = i; - break; - } - } - if(index_start == -1) { - osd_print(9*16+0, true, "Index end error "); - return -2; - } - int index_size = index_end - index_start; - - int index = 0; - - while(true) { - //print contents - for(int i=-5; i<7; i++) { - if((index + i < 0) || (index + i > index_size)) { - osd_print((9+i)*16, false, " "); - } - else { - int current_index = index_start + index + i; - bool invert = i == 0; - osd_print((9+i)*16, invert, " "); - osd_print((9+i)*16, invert, " %s", entries[current_index].name); - } - } - - char key = 0; - while(key == 0) { - uint32 keys = IORD(PIO_INPUT_BASE, 0); - - if((keys & 0x1) == 0) key = 'v'; - else if((keys & 0x2) == 0) key = '^'; - else if((keys & 0x4) == 0) key = 'Y'; - else key = 0; - } - - if(key == 'Y') return index; - - if(key == '^' && index > 0) index--; - if(key == 'v' && index < index_size) index++; - - usleep(300000); - } -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- SD read header - - IOWR(SD_CARD_BASE, 0, (int)entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, 0); //SD sector - IOWR(SD_CARD_BASE, 2, sizeof(entries)/512); //sector count - IOWR(SD_CARD_BASE, 3, 2); //control READ - - //wait for ready - sd_status = -1; - while(sd_status != 2) { - usleep(100000); - sd_status = IORD(SD_CARD_BASE, 0); - } - - //check crc32 - bool crc_ok = false; - for(int i=0; i 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - //do nothing - if(ptr != NULL && crc_output != NULL) return; - - //initialize - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - //output - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[15]; - uint32 sector; - uint32 size_in_bytes; - uint32 destination; - uint32 crc32; - } bios; - struct floppy_t { - uint8 type; - uint8 name[15]; - uint32 sector; - }; - struct end_of_list_t { - uint8 byte; - uint8 name[15]; - uint32 crc32; - }; -}; - -#pragma pack(pop) - -union entry_t entries[128]; - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0*16+0, false, "ao486 SoC ver1.0"); - - osd_print(1*16+0, false, "SD init... "); - osd_print(2*16+0, false, "SD header chk..."); - - //-------------------------------------------------------------------------- check sd card presence - usleep(1000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status != 2) { - osd_print(1*16+0, true, "SD reinit: %d ", sd_status); - - while(sd_status == 0) { - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status == 1) { - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(1000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - } - osd_print(1*16+0, false, "SD OK "); - - //-------------------------------------------------------------------------- - - IOWR(SD_CARD_BASE, 0, entries); //Avalon address base - IOWR(SD_CARD_BASE, 1, ) - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - - while(true) { ; } - - //-------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //-------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //-------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //-------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i -#include -#include -#include - -#include -#include -#include - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_print(0, false, "Hello world 2"); - - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = false; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i sizeof(read_buf))? sizeof(read_buf) : size-i; - for(unsigned int j=0; j -#include -#include -#include - -#include -#include -#include - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; - - -void osd_enable(bool enable) { - IOWR(VGA_BASE, 0, 0x8000 | ((enable)? 0x4000 : 0x0000)); -} - -void osd_print(int position, bool invert, const char *format, ...) { - va_list ap; - - va_start(ap, format); - - char buf[64]; - memset((void *)buf, 0, (unsigned long int)sizeof(buf)); - - int written = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - - for(int i=0; i> 15) & 1) return rd & 0xFF; - } -} - -unsigned int read_int() { - unsigned int rd = 0; - rd |= read_byte() << 0; - rd |= read_byte() << 8; - rd |= read_byte() << 16; - rd |= read_byte() << 24; - return rd; -} - -void crc32(unsigned char *ptr, unsigned int *crc_output) { - static unsigned char crc[32]; - - if(ptr != NULL && crc_output != NULL) return; - - if(ptr == NULL && crc_output == NULL) { - for(int i=0; i<32; i++) crc[i] = 1; - return; - } - - if(ptr == NULL && crc_output != NULL) { - *crc_output = 0; - for(int i=0; i<32; i++) { - (*crc_output) |= crc[i] << (31-i); - } - (*crc_output) = ~(*crc_output); - return; - } - - unsigned char in[8]; - for(int j=0; j<8; j++) in[j] = ((*ptr) >> j) & 1; - - unsigned char new_crc[32]; - - new_crc[31] = in[2] ^ crc[23] ^ crc[29]; - new_crc[30] = in[0] ^ in[3] ^ crc[22] ^ crc[28] ^ crc[31]; - new_crc[29] = in[0] ^ in[1] ^ in[4] ^ crc[21] ^ crc[27] ^ crc[30] ^ crc[31]; - new_crc[28] = in[1] ^ in[2] ^ in[5] ^ crc[20] ^ crc[26] ^ crc[29] ^ crc[30]; - new_crc[27] = in[0] ^ in[2] ^ in[3] ^ in[6] ^ crc[19] ^ crc[25] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[26] = in[1] ^ in[3] ^ in[4] ^ in[7] ^ crc[18] ^ crc[24] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[25] = in[4] ^ in[5] ^ crc[17] ^ crc[26] ^ crc[27]; - new_crc[24] = in[0] ^ in[5] ^ in[6] ^ crc[16] ^ crc[25] ^ crc[26] ^ crc[31]; - new_crc[23] = in[1] ^ in[6] ^ in[7] ^ crc[15] ^ crc[24] ^ crc[25] ^ crc[30]; - new_crc[22] = in[7] ^ crc[14] ^ crc[24]; - new_crc[21] = in[2] ^ crc[13] ^ crc[29]; - new_crc[20] = in[3] ^ crc[12] ^ crc[28]; - new_crc[19] = in[0] ^ in[4] ^ crc[11] ^ crc[27] ^ crc[31]; - new_crc[18] = in[0] ^ in[1] ^ in[5] ^ crc[10] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[17] = in[1] ^ in[2] ^ in[6] ^ crc[9] ^ crc[25] ^ crc[29] ^ crc[30]; - new_crc[16] = in[2] ^ in[3] ^ in[7] ^ crc[8] ^ crc[24] ^ crc[28] ^ crc[29]; - new_crc[15] = in[0] ^ in[2] ^ in[3] ^ in[4] ^ crc[7] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[31]; - new_crc[14] = in[0] ^ in[1] ^ in[3] ^ in[4] ^ in[5] ^ crc[6] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30] ^ crc[31]; - new_crc[13] = in[0] ^ in[1] ^ in[2] ^ in[4] ^ in[5] ^ in[6] ^ crc[5] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[12] = in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ in[7] ^ crc[4] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30]; - new_crc[11] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[3] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[10] = in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[2] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29]; - new_crc[9] = in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[1] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29]; - new_crc[8] = in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[0] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28]; - new_crc[7] = in[0] ^ in[2] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[29] ^ crc[31]; - new_crc[6] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[5] = in[0] ^ in[1] ^ in[2] ^ in[3] ^ in[4] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[27] ^ crc[28] ^ crc[29] ^ crc[30] ^ crc[31]; - new_crc[4] = in[1] ^ in[3] ^ in[4] ^ in[5] ^ in[7] ^ crc[24] ^ crc[26] ^ crc[27] ^ crc[28] ^ crc[30]; - new_crc[3] = in[0] ^ in[4] ^ in[5] ^ in[6] ^ crc[25] ^ crc[26] ^ crc[27] ^ crc[31]; - new_crc[2] = in[0] ^ in[1] ^ in[5] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[26] ^ crc[30] ^ crc[31]; - new_crc[1] = in[0] ^ in[1] ^ in[6] ^ in[7] ^ crc[24] ^ crc[25] ^ crc[30] ^ crc[31]; - new_crc[0] = in[1] ^ in[7] ^ crc[24] ^ crc[30]; - - memcpy(crc, new_crc, sizeof(crc)); -} - -#pragma pack(push) -#pragma pack(1) - -union entry_t { - struct bios_t { - uint8 type; - uint8 name[17]; - uint8 padding[2]; - uint32 sector; - uint32 size_in_bytes; - uint32 crc32; - } bios; -}; - -#pragma pack(pop) - -int main() { - - //pc_bus - IOWR(PC_BUS_BASE, 0, 0x00FFF0EA); - IOWR(PC_BUS_BASE, 1, 0x000000F0); - - //resets output - IOWR(PIO_OUTPUT_BASE, 0, 0x01); - - //vga - osd_enable(false); - usleep(1000000); - - for(int i=0; i<16*16; i++) IOWR(VGA_BASE, i, 0); - - osd_enable(true); - - osd_border(); - - while(true) { ; } - //check sd card presence - usleep(2000000); - int sd_status = IORD(SD_CARD_BASE, 0); - while(sd_status == 1) { - osd_print(32, true, "SD reinit..."); - IOWR(SD_CARD_BASE, 3, 1); //control reinit; - IOWR(SD_CARD_BASE, 3, 0); //control idle; - - usleep(4000000); - sd_status = IORD(SD_CARD_BASE, 0); - } - if(sd_status != 2) { - osd_print(32, true, "SD failed: %d", sd_status); - return 0; - } - osd_print(32, false, "SD OK "); - //--------------------------------------------------------------------------------------------- sound - /* - 0-255.[15:0]: cycles in period - 256.[12:0]: cycles in 80us - 257.[9:0]: cycles in 1 sample: 96000 Hz - */ - - double cycle_in_ns = (1000000000.0 / ALT_CPU_CPU_FREQ); //33.333333; - for(int i=0; i<256; i++) { - double f = 1000000.0 / (256.0-i); - - double cycles_in_period = 1000000000.0 / (f * cycle_in_ns); - IOWR(SOUND_BASE, i, (int)cycles_in_period); - } - - IOWR(SOUND_BASE, 256, (int)(80000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(SOUND_BASE, 257, (int)((1000000000.0/96000.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- pit - /* - 0.[7:0]: cycles in sysclock 1193181 Hz - */ - - IOWR(PIT_BASE, 0, (int)((1000000000.0/1193181.0) / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - //--------------------------------------------------------------------------------------------- floppy - - bool floppy_is_160k = false; - bool floppy_is_180k = false; - bool floppy_is_320k = false; - bool floppy_is_360k = false; - bool floppy_is_720k = false; - bool floppy_is_1_2m = false; - bool floppy_is_1_44m= true; - bool floppy_is_2_88m= false; - - bool floppy_present = true; - bool floppy_writeprotect = true; - - int floppy_sd_base = 0x00000103; - - /* - 0x00.[0]: media present - 0x01.[0]: media writeprotect - 0x02.[7:0]: media cylinders - 0x03.[7:0]: media sectors per track - 0x04.[31:0]: media total sector count - 0x05.[1:0]: media heads - 0x06.[31:0]: media sd base - 0x07.[15:0]: media wait cycles: 200000 us / spt - 0x08.[15:0]: media wait rate 0: 1000 us - 0x09.[15:0]: media wait rate 1: 1666 us - 0x0A.[15:0]: media wait rate 2: 2000 us - 0x0B.[15:0]: media wait rate 3: 500 us - 0x0C.[7:0]: media type: 8'h20 none; 8'h00 old; 8'hC0 720k; 8'h80 1_44M; 8'h40 2_88M - */ - - int floppy_cylinders = (floppy_is_2_88m || floppy_is_1_44m || floppy_is_1_2m || floppy_is_720k)? 80 : 40; - int floppy_spt = - (floppy_is_160k)? 8 : - (floppy_is_180k)? 9 : - (floppy_is_320k)? 8 : - (floppy_is_360k)? 9 : - (floppy_is_720k)? 9 : - (floppy_is_1_2m)? 15 : - (floppy_is_1_44m)? 18 : - (floppy_is_2_88m)? 36 : - 0; - int floppy_total_sectors = - (floppy_is_160k)? 320 : - (floppy_is_180k)? 360 : - (floppy_is_320k)? 640 : - (floppy_is_360k)? 720 : - (floppy_is_720k)? 1440 : - (floppy_is_1_2m)? 2400 : - (floppy_is_1_44m)? 2880 : - (floppy_is_2_88m)? 5760 : - 0; - int floppy_heads = (floppy_is_160k || floppy_is_180k)? 1 : 2; - - int floppy_wait_cycles = 200000000 / floppy_spt; - - int floppy_media = - (!floppy_present)? 0x20 : - (floppy_is_160k)? 0x00 : - (floppy_is_180k)? 0x00 : - (floppy_is_320k)? 0x00 : - (floppy_is_360k)? 0x00 : - (floppy_is_720k)? 0xC0 : - (floppy_is_1_2m)? 0x00 : - (floppy_is_1_44m)? 0x80 : - (floppy_is_2_88m)? 0x40 : - 0x20; - - IOWR(FLOPPY_BASE, 0x0, floppy_present? 1 : 0); - IOWR(FLOPPY_BASE, 0x1, floppy_writeprotect? 1 : 0); - IOWR(FLOPPY_BASE, 0x2, floppy_cylinders); - IOWR(FLOPPY_BASE, 0x3, floppy_spt); - IOWR(FLOPPY_BASE, 0x4, floppy_total_sectors); - IOWR(FLOPPY_BASE, 0x5, floppy_heads); - IOWR(FLOPPY_BASE, 0x6, floppy_sd_base); - IOWR(FLOPPY_BASE, 0x7, (int)(floppy_wait_cycles / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x8, (int)(1000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0x9, (int)(1666666.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xA, (int)(2000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xB, (int)(500000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(FLOPPY_BASE, 0xC, floppy_media); - - //--------------------------------------------------------------------------------------------- hdd - - unsigned int hd_cylinders = 1024; //1-1024; 10 bits; implemented 16 bits - unsigned int hd_heads = 16; //1-16; 4 bits; at least 9 heads for cmos 0x20 - unsigned int hd_spt = 63; //1-255; 8 bits; - - int hdd_sd_base = 1000000; - - unsigned int hd_total_sectors = hd_cylinders * hd_heads * hd_spt; - - /* - 0x00.[31:0]: identify write - 0x01.[16:0]: media cylinders - 0x02.[4:0]: media heads - 0x03.[8:0]: media spt - 0x04.[13:0]: media sectors per cylinder = spt * heads - 0x05.[31:0]: media sectors total - 0x06.[31:0]: media sd base - */ - - unsigned int identify[256] = { - 0x0040, //word 0 - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 1 - 0x0000, //word 2 reserved - hd_heads, //word 3 - (unsigned short)(512 * hd_spt), //word 4 - 512, //word 5 - hd_spt, //word 6 - 0x0000, //word 7 vendor specific - 0x0000, //word 8 vendor specific - 0x0000, //word 9 vendor specific - ('A' << 8) | 'O', //word 10 - ('H' << 8) | 'D', //word 11 - ('0' << 8) | '0', //word 12 - ('0' << 8) | '0', //word 13 - ('0' << 8) | ' ', //word 14 - (' ' << 8) | ' ', //word 15 - (' ' << 8) | ' ', //word 16 - (' ' << 8) | ' ', //word 17 - (' ' << 8) | ' ', //word 18 - (' ' << 8) | ' ', //word 19 - 3, //word 20 buffer type - 512, //word 21 cache size - 4, //word 22 number of ecc bytes - 0,0,0,0, //words 23..26 firmware revision - ('A' << 8) | 'O', //words 27..46 model number - (' ' << 8) | 'H', - ('a' << 8) | 'r', - ('d' << 8) | 'd', - ('r' << 8) | 'i', - ('v' << 8) | 'e', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - (' ' << 8) | ' ', - 16, //word 47 max multiple sectors - 1, //word 48 dword io - 1<<9, //word 49 lba supported - 0x0000, //word 50 reserved - 0x0200, //word 51 pio timing - 0x0200, //word 52 pio timing - 0x0007, //word 53 valid fields - (hd_cylinders > 16383)? 16383 : hd_cylinders, //word 54 - hd_heads, //word 55 - hd_spt, //word 56 - hd_total_sectors & 0xFFFF, //word 57 - hd_total_sectors >> 16, //word 58 - 0x0000, //word 59 multiple sectors - hd_total_sectors & 0xFFFF, //word 60 - hd_total_sectors >> 16, //word 61 - 0x0000, //word 62 single word dma modes - 0x0000, //word 63 multiple word dma modes - 0x0000, //word 64 pio modes - 120,120,120,120, //word 65..68 - 0,0,0,0,0,0,0,0,0,0,0, //word 69..79 - 0x007E, //word 80 ata modes - 0x0000, //word 81 minor version number - 1<<14, //word 82 supported commands - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 83 - 1<<14, //word 84 - 1<<14, //word 85 - (1<<14) | (1<<13) | (1<<12) | (1<<10), //word 86 - 1<<14, //word 87 - 0x0000, //word 88 - 0,0,0,0, //word 89..92 - 1 | (1<<14) | 0x2000, //word 93 - 0,0,0,0,0,0, //word 94..99 - hd_total_sectors & 0xFFFF, //word 100 - hd_total_sectors >> 16, //word 101 - 0, //word 102 - 0, //word 103 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//word 104..127 - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //word 128..255 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - - - for(int i=0; i<128; i++) IOWR(HDD_BASE, 0, ((unsigned int)identify[2*i+1] << 16) | (unsigned int)identify[2*i+0]); - - IOWR(HDD_BASE, 1, hd_cylinders); - IOWR(HDD_BASE, 2, hd_heads); - IOWR(HDD_BASE, 3, hd_spt); - IOWR(HDD_BASE, 4, hd_spt * hd_heads); - IOWR(HDD_BASE, 5, hd_spt * hd_heads * hd_cylinders); - IOWR(HDD_BASE, 6, hdd_sd_base); - - //--------------------------------------------------------------------------------------------- rtc - - bool boot_from_floppy = true; - - /* - 128.[26:0]: cycles in second - 129.[12:0]: cycles in 122.07031 us - */ - - IOWR(RTC_BASE, 128, (int)(1000000000.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - IOWR(RTC_BASE, 129, (int)(122070.0 / (1000000000.0 / ALT_CPU_CPU_FREQ))); - - unsigned char fdd_type = (floppy_is_2_88m)? 0x50 : (floppy_is_1_44m)? 0x40 : (floppy_is_720k)? 0x30 : (floppy_is_1_2m)? 0x20 : 0x10; - - bool translate_none = hd_cylinders <= 1024 && hd_heads <= 16 && hd_spt <= 63; - bool translate_large= !translate_none && (hd_cylinders * hd_heads) <= 131072; - bool translate_lba = !translate_none && !translate_large; - - unsigned char translate_byte = (translate_large)? 1 : (translate_lba)? 2 : 0; - - //rtc contents 0-127 - unsigned int cmos[128] = { - 0x00, //0x00: SEC BCD - 0x00, //0x01: ALARM SEC BCD - 0x00, //0x02: MIN BCD - 0x00, //0x03: ALARM MIN BCD - 0x12, //0x04: HOUR BCD 24h - 0x12, //0x05: ALARM HOUR BCD 24h - 0x01, //0x06: DAY OF WEEK Sunday=1 - 0x03, //0x07: DAY OF MONTH BCD from 1 - 0x11, //0x08: MONTH BCD from 1 - 0x13, //0x09: YEAR BCD - 0x26, //0x0A: REG A - 0x02, //0x0B: REG B - 0x00, //0x0C: REG C - 0x80, //0x0D: REG D - 0x00, //0x0E: REG E - POST status - 0x00, //0x0F: REG F - shutdown status - - fdd_type, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M - 0x00, //0x11: configuration bits; not used - 0xF0, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ - 0x00, //0x13: advanced configuration bits; not used - 0x0D, //0x14: equipment bits - 0x80, //0x15: base memory in 1k LSB - 0x02, //0x16: base memory in 1k MSB - 0x00, //0x17: memory size above 1m in 1k LSB - 0xFC, //0x18: memory size above 1m in 1k MSB - 0x2F, //0x19: extended hd types 1/2; type 47d - 0x00, //0x1A: extended hd types 2/2 - - hd_cylinders & 0xFF, //0x1B: hd 0 configuration 1/9; cylinders low - (hd_cylinders >> 8) & 0xFF, //0x1C: hd 0 configuration 2/9; cylinders high - hd_heads, //0x1D: hd 0 configuration 3/9; heads - 0xFF, //0x1E: hd 0 configuration 4/9; write pre-comp low - 0xFF, //0x1F: hd 0 configuration 5/9; write pre-comp high - 0xC8, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 - hd_cylinders & 0xFF, //0x21: hd 0 configuration 7/9; landing zone low - (hd_cylinders >> 8) & 0xFF, //0x22: hd 0 configuration 8/9; landing zone high - hd_spt, //0x23: hd 0 configuration 9/9; sectors/track - - 0x00, //0x24: hd 1 configuration 1/9 - 0x00, //0x25: hd 1 configuration 2/9 - 0x00, //0x26: hd 1 configuration 3/9 - 0x00, //0x27: hd 1 configuration 4/9 - 0x00, //0x28: hd 1 configuration 5/9 - 0x00, //0x29: hd 1 configuration 6/9 - 0x00, //0x2A: hd 1 configuration 7/9 - 0x00, //0x2B: hd 1 configuration 8/9 - 0x00, //0x2C: hd 1 configuration 9/9 - - (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence - - 0x00, //0x2E: checksum MSB - 0x00, //0x2F: checksum LSB - - 0x00, //0x30: memory size above 1m in 1k LSB - 0xFC, //0x31: memory size above 1m in 1k MSB - - 0x20, //0x32: IBM century - 0x00, //0x33: ? - - 0x00, //0x34: memory size above 16m in 64k LSB - 0x07, //0x35: memory size above 16m in 64k MSB; 128 MB - - 0x00, //0x36: ? - 0x20, //0x37: IBM PS/2 century - - 0x00, //0x38: eltorito boot sequence; not used - translate_byte, //0x39: ata translation policy 1/2 - 0x00, //0x3A: ata translation policy 2/2 - - 0x00, //0x3B: ? - 0x00, //0x3C: ? - - 0x00, //0x3D: eltorito boot sequence; not used - - 0x00, //0x3E: ? - 0x00, //0x3F: ? - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - //count checksum - unsigned short sum = 0; - for(int i=0x10; i<=0x2D; i++) sum += cmos[i]; - - cmos[0x2E] = sum >> 8; - cmos[0x2F] = sum & 0xFF; - - for(unsigned int i=0; i\n\n\n\n\n\n\n\n diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index c77c906..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -properties/exe.null.1152093374/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1694449736=\#\n\#Sun Mar 30 13\:37\:50 CEST 2014\naltera.nios2.linux.gcc4.794989974\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.libs.1891943012\=\\\#\\n\\\#Sat Nov 02 21\\\:35\\\:45 CET 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1684827519\=\\\#\\n\\\#Sat Nov 02 21\\\:35\\\:45 CET 2013\\nrebuildState\\\=true\\n\norg.eclipse.cdt.build.core.settings.holder.2081315115\=\\\#\\n\\\#Sat Nov 02 21\\\:35\\\:45 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.51979996\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1694449736\=\\\#\\n\\\#Sun Mar 30 13\\\:36\\\:33 CEST 2014\\nrcState\\\=0\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.1134065603\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.828310578\=\\\#\\n\\\#Sat Nov 02 21\\\:35\\\:45 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.807650954\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1145781037\=\\\#\\n\\\#Sat Nov 02 21\\\:35\\\:45 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.assembler.base.689559324\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.482324696\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.archiver.base.648434271\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\n -properties/exe_bsp.null.523642357/preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.8480639=\#\n\#Sun Mar 30 13\:37\:50 CEST 2014\ncdt.managedbuild.tool.gnu.archiver.base.937339506\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.2120508724\=\\\#\\n\\\#Sat Nov 02 21\\\:30\\\:07 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.compiler.base.604839035\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.compiler.base.1214000695\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.libs.707634006\=\\\#\\n\\\#Sat Nov 02 21\\\:30\\\:07 CET 2013\\nrebuildState\\\=true\\n\naltera.nios2.linux.gcc4.460557445\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1372035439\=\\\#\\n\\\#Sat Nov 02 21\\\:30\\\:07 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.assembler.base.1466549746\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.prefbase.toolchain.1107287232\=\\\#\\n\\\#Sat Nov 02 21\\\:30\\\:07 CET 2013\\nrebuildState\\\=true\\n\npreference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.8480639\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrcState\\\=0\\nrebuildState\\\=false\\n\norg.eclipse.cdt.build.core.settings.holder.1188524749\=\\\#\\n\\\#Sat Nov 02 21\\\:30\\\:07 CET 2013\\nrebuildState\\\=true\\n\ncdt.managedbuild.tool.gnu.cpp.linker.base.1334939375\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\ncdt.managedbuild.tool.gnu.c.linker.base.2078691152\=\\\#\\n\\\#Sun Mar 30 13\\\:37\\\:50 CEST 2014\\nrebuildState\\\=false\\n\n diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs deleted file mode 100644 index 0451f54..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.mylyn.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.cdt.ui.run.count.3_3_0=1 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs deleted file mode 100644 index 2680b72..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs +++ /dev/null @@ -1,10 +0,0 @@ -content_assist_disabled_computers=org.eclipse.cdt.ui.parserProposalCategory\u0000org.eclipse.cdt.ui.textProposalCategory\u0000 -eclipse.preferences.version=1 -hoverModifierMasks=org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover;0;org.eclipse.cdt.ui.ProblemHover;0;org.eclipse.cdt.ui.CDocHover;0;org.eclipse.cdt.ui.CMacroExpansionHover;0;org.eclipse.cdt.ui.CSourceHover;131072;org.eclipse.cdt.ui.AnnotationHover;0; -hoverModifiers=org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover;\!0;org.eclipse.cdt.ui.ProblemHover;\!0;org.eclipse.cdt.ui.CDocHover;\!0;org.eclipse.cdt.ui.CMacroExpansionHover;\!0;org.eclipse.cdt.ui.CSourceHover;Shift;org.eclipse.cdt.ui.AnnotationHover;\!0; -org.eclipse.cdt.ui.text.templates.custom= -sourceHoverBackgroundColor=214,210,208 -spelling_locale_initialized=true -spelling_user_dictionary_encoding= -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index a7fb09f..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -description.autobuilding=false -eclipse.preferences.version=1 -version=1 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs deleted file mode 100644 index 57e3b77..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug;org.eclipse.cdt.cdi.launch.localCLaunch,run -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug -//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.remoteApplicationLaunchType=org.eclipse.rse.remotecdt.dsf.debug,debug -eclipse.preferences.version=1 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs deleted file mode 100644 index a2917e5..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n -preferredTargets=org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget| diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs deleted file mode 100644 index fafaeaa..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.epp.usagedata.recording.last-upload=1396179389348 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs deleted file mode 100644 index 43e97e4..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -mylyn.attention.migrated=true diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs deleted file mode 100644 index 8d462a6..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs deleted file mode 100644 index cec65c4..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.search.defaultPerspective=org.eclipse.search.defaultPerspective.none diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs deleted file mode 100644 index f9e585b..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -pref_first_startup=false diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs deleted file mode 100644 index 56cd496..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.team.ui.first_time=false diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs deleted file mode 100644 index 031cfa6..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -lineNumberRuler=true -overviewRuler_migration=migrated_3.1 -printMargin=true -spacesForTabs=true diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index 8ac503a..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,6 +0,0 @@ -PROBLEMS_FILTERS_MIGRATE=true -TASKS_FILTERS_MIGRATE=true -eclipse.preferences.version=1 -platformState=1389119422680 -quickStart=false -tipsAndTricks=true diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index 08076f2..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -showIntro=false diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs deleted file mode 100644 index c857a75..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ /dev/null @@ -1,3 +0,0 @@ -ENABLED_DECORATORS=com.altera.sbtgui.project.decorator.bsp\:true,com.altera.sbtgui.project.nios2builddecorator\:true,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false, -PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.cdt.codan.ui.cxx; -eclipse.preferences.version=1 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch b/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch deleted file mode 100644 index cfdd310..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.core/.launches/exe.launch +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml deleted file mode 100644 index 840f06e..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- - - - - - -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 795c14e..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv deleted file mode 100644 index 0e43f4f..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload0.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1383424076361 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1383424076361 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1383424076362 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383424076362 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1383424076362 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383424076362 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383424076362 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383424076362 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383424076362 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383424076362 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383424076362 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383424076362 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1383424076362 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1383424076363 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1383424076363 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1383424076363 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1383424076363 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1383424076363 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1383424076363 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1383424076363 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1383424076363 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1383424076364 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1383424076364 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1383424076364 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383424076364 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383424076364 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1383424076364 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1383424076364 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1383424076364 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1383424076364 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1383424076364 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1383424076365 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1383424076365 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1383424076365 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1383424076365 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1383424076365 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1383424076365 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1383424076365 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1383424076365 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1383424076365 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1383424076365 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383424076365 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1383424076366 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383424076366 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1383424076366 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1383424076366 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1383424076366 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1383424076366 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383424076366 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1383424076366 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383424076366 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383424076366 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383424076366 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1383424076366 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1383424076366 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383424076366 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383424076366 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1383424076366 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1383424076366 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1383424076366 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1383424076367 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1383424076367 -started,bundle,org.eclipse.ui.intro,3.4.100.v20110425,"org.eclipse.ui.intro",1383424076367 -started,bundle,org.eclipse.ui.intro.universal,3.2.500.v20110510,"org.eclipse.ui.intro.universal",1383424076367 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1383424076367 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383424076367 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1383424076367 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1383424076367 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1383424076367 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1383424076367 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1383424076367 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1383424076367 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1383424076367 -started,bundle,com.altera.sbtgui.integration,13.13.0.132,"com.altera.sbtgui.integration",1383424076368 -started,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1383424076368 -started,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1383424076368 -started,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1383424076368 -started,bundle,com.altera.systemconsole,13.13.0.132,"com.altera.systemconsole",1383424076368 -started,bundle,com.altera.systemconsole.designs.plugin,13.13.0.132,"com.altera.systemconsole.designs.plugin",1383424076368 -started,bundle,com.altera.utilities,13.13.0.132,"com.altera.utilities",1383424076368 -os,sysinfo,,,"linux",1383424076370 -arch,sysinfo,,,"x86",1383424076370 -ws,sysinfo,,,"gtk",1383424076370 -locale,sysinfo,,,"en_US",1383424076370 -processors,sysinfo,,,"8",1383424076371 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1383424076371 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1383424076371 -java.specification.name,sysinfo,,,"Java Platform API Specification",1383424076371 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383424076371 -java.specification.version,sysinfo,,,"1.6",1383424076371 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1383424076371 -java.version,sysinfo,,,"1.6.0_23",1383424076371 -java.vm.info,sysinfo,,,"mixed mode",1383424076371 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1383424076371 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1383424076371 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383424076371 -java.vm.specification.version,sysinfo,,,"1.0",1383424076371 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1383424076371 -java.vm.version,sysinfo,,,"19.0-b09",1383424076371 -activated,view,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.internal.introview",1383424079326 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424079330 -started,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1383424089471 -started,bundle,com.altera.sbtgui.integration.jars,13.13.0.132,"com.altera.sbtgui.integration.jars",1383424089735 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424090109 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424092045 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424092070 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424139340 -opened,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383424146745 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383424146848 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383424146853 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383424146853 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383424146853 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424147000 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383424205259 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1383424205302 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383424206827 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424209876 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424213154 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424443690 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1383424445417 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383424445420 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424448154 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424503743 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424505741 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424515558 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424521212 -started,bundle,org.eclipse.core.databinding,1.4.0.I20110111-0800,"org.eclipse.core.databinding",1383424524376 -started,bundle,org.eclipse.core.databinding.property,1.4.0.I20110222-0800,"org.eclipse.core.databinding.property",1383424524382 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1383424537622 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424537629 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424537918 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424538008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424540609 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424541800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424544751 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424599288 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424607562 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424607627 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424607647 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383424608033 -opened,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1383424671015 -activated,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1383424671114 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424671135 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1383424672620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424672919 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424673165 -activated,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1383424685534 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1383424686483 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424686491 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424713105 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424714734 -closed,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1383424714735 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424715730 -opened,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424716349 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424716384 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424716399 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424719010 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424800669 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424803934 -closed,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424805726 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1383424805770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383424805770 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424805780 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424806939 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424806959 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424811140 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1383424812779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383424812779 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424812790 -opened,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424816557 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424816583 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424816599 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424819039 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424819106 -closed,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383424819106 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424819998 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424823164 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424828720 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424830750 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1383424832644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383424832645 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424832655 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424832707 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424833126 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424835600 -executed,command,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring.commands.deleteResources",1383424836551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383424836551 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424836560 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424837113 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383424837126 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424837225 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424838190 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424843529 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424846816 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424847132 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424847189 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424847240 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424847290 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424847370 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424848205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383424851067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383424863279 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383424866843 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424870377 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424871519 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424872082 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424873013 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424877997 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424878765 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424879848 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424959424 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424966611 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383424995969 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383424998429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425003883 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425007840 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425008792 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425022048 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425025146 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425025544 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425032560 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425035460 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425130174 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425137367 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425141513 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383425147000 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425147191 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425147245 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383425147260 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425149686 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383425160865 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383425164775 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425165695 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383425165711 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425167551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383425168796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425171081 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425172478 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425174292 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425175497 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425176439 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425189224 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383425191078 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425199401 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425202099 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425212504 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425214939 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425340042 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425343742 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425347229 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425350843 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425753485 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425788040 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383425794356 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425795933 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383425796862 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425848715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425859466 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425869916 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383425870617 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383425870621 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425871456 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383425877083 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425882149 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383425895998 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425904395 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425921058 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425924642 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383425940585 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425943941 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425980493 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383425985710 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425988129 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383425988436 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383425991966 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv deleted file mode 100644 index f077ef9..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload1.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426001994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383426003050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383426003855 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426004506 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426007151 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426043464 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426056055 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426061693 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426062435 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426066092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426069641 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426070521 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426077164 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426080819 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426082171 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426085737 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426086444 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426122167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426127760 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426129240 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426201175 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426204912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426218624 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426235478 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426245715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426274928 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426288015 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426297279 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426300726 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426307272 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426314597 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426318368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426329718 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426375634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426375834 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426379522 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426379682 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426379849 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426379993 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426380145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426380297 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383426380473 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426418056 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426447015 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383426449236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426450797 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426451111 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383426457523 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426482551 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383426484521 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426486060 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426486372 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426500753 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426524068 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426526362 -started,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1383426529830 -started,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1383426541183 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426585374 -started,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1383426585903 -started,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1383426585909 -error,log,,,"Failed Executing: [nios2-download, '--cable=USB-Blaster on localhost [3-1.6]', --device=1, --instance=0, --go, --accept-bad-sysid, --reset-target, /home/alek/aktualne/ao486/syn/soc/firmware/exe/exe.elf] return code: 4, 'other error'",1383426588791 -error,log,,,"Downloading ELF Process failed",1383426588793 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426588841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426591305 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426601897 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426678551 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383426678570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426679765 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383426681301 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426683247 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426683539 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426688564 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426771998 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383426774481 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426779228 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426781081 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426800564 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426835603 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383426837029 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383426858229 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426859982 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426866483 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426868953 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383426963752 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383426965923 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383426977174 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426982339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383426996058 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383427016633 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383427018770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383427042281 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383427046738 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383427049762 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383427111367 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383427115761 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383427119976 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383427122738 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383427124657 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383427144547 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428023863 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428029220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428041823 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428043318 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1383428071137 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428071143 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428089287 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428091213 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428093131 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428101990 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428109434 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428147442 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428154573 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428189837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428196924 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383428198635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428199782 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428205019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428262108 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428337954 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428340486 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428341473 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428358842 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428434666 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428435951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428436256 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.goto.wordPrevious",1383428474069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428478579 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428482874 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428483018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428496658 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428503460 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428504693 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428509977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428512552 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428513826 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428515282 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428538489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383428542737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428544282 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428549137 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428552328 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428555249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383428561271 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383428562616 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383428564384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383428564809 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383428580253 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428581844 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428582144 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383428588567 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429053948 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429059622 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429374584 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429375011 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429378654 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429379325 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429469567 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383429471443 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429474225 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429495430 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429501452 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429505871 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429508181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429508364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429509727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429510602 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429511292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429515114 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383429520225 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383429524603 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429536210 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429538727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429539066 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429551238 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429562442 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429567240 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429568447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429570128 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429582474 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429586210 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429588646 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429589764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429595200 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429634585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429636360 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429647865 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429699637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429703056 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429706203 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429706419 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429706610 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429706787 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429714784 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383429717687 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383429732017 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429745817 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429748805 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429749215 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429757001 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429760479 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429761080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383429777466 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383429779192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429783776 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383429787973 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429788563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429792080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429793320 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429796767 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429822340 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429824324 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383429828157 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429831975 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429832912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429836198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429847119 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383429857568 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429858614 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429860680 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429862320 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429886049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383429887872 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383429891932 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429895007 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383429905478 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429908995 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383429910450 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383433759725 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383433761497 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383433763811 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434431347 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434438407 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434670981 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434675955 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434819810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383434851358 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383434860272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383434862550 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434864690 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434866562 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434867810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434868890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434869802 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434870515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434871370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434872170 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434872914 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434873522 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434874114 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434874739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434875299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383434875882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383434878124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383434898989 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434902236 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434956565 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383434964404 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383434984789 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383434998492 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435000834 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435013051 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435014007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435015848 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435016695 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435024479 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435028958 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435080769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435089587 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435096853 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435098901 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435105247 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435107051 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435117355 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435130272 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435132811 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload10.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload10.csv deleted file mode 100644 index aedda68..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload10.csv +++ /dev/null @@ -1,255 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521654354 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521655285 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521656688 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521659401 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521660060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521682580 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383521686050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1383521686283 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521686289 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521690882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521699384 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383521700997 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521702523 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521703114 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521705520 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521766461 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521770953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521811391 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383521815455 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521817228 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521817574 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521819090 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521911544 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521922206 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521929423 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383521933257 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521935007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521935360 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521946873 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594285822 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594290539 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594293318 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594295655 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594298595 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594302213 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594302482 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594305162 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594306059 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594306100 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594306847 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383594308825 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383600207779 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383600322778 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383689025603 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383689037834 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383689523437 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383689523484 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383689525425 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1383689525604 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383689525604 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.13.0.132,"com.altera.debug.cdi.gdb.plugin",1383689525605 -stopped,bundle,com.altera.sbtgui.launch,13.13.0.132,"com.altera.sbtgui.launch",1383689525605 -stopped,bundle,com.altera.sbtgui.ui,13.13.0.132,"com.altera.sbtgui.ui",1383689525605 -stopped,bundle,com.altera.sbtgui.project,13.13.0.132,"com.altera.sbtgui.project",1383689525605 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383689525605 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383689525605 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383689525605 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1383689525605 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1383689525605 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1383689525605 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1383689525605 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1383689525605 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383689525606 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1383689525606 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1383689525606 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383689525606 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1383689525607 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383689525607 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1383689525607 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383689525607 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383689525607 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1383689525607 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383689525607 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1383689525608 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383689525609 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1383689525609 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383689525609 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383689525609 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383689525609 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383689525610 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383689525610 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.13.0.132,"com.altera.sbtgui.flash.plugin",1383689525610 -stopped,bundle,com.altera.sbtgui.gprof,13.13.0.132,"com.altera.sbtgui.gprof",1383689525610 -stopped,bundle,com.altera.sbtgui.core,13.13.0.132,"com.altera.sbtgui.core",1383689525610 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383689525611 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383689525611 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383689525612 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383689525612 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1383689525612 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1383689525612 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1383689525612 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1383689525612 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1383689525612 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383689525616 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1383689525616 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383689525617 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383689525617 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383689525617 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1383689525617 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1383689525617 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383689525617 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383689525618 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383689525618 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383689525618 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1383689525618 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1383689525618 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383689525622 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1383689525622 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1383689525622 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.files.ssh,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.ssh",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.shells.ssh,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.ssh",1383689525622 -stopped,bundle,org.eclipse.rse.subsystems.terminals.ssh,1.0.100.v201101042155,"org.eclipse.rse.subsystems.terminals.ssh",1383689525623 -stopped,bundle,org.eclipse.rse.connectorservice.ssh,2.1.200.v201101042155,"org.eclipse.rse.connectorservice.ssh",1383689525623 -stopped,bundle,org.eclipse.rse.connectorservice.telnet,1.2.200.v201101042155,"org.eclipse.rse.connectorservice.telnet",1383689525623 -stopped,bundle,org.eclipse.rse.dstore.security,3.0.300.v201103141607,"org.eclipse.rse.dstore.security",1383689525623 -stopped,bundle,org.eclipse.rse.efs,2.1.300.v201101042155,"org.eclipse.rse.efs",1383689525623 -stopped,bundle,org.eclipse.rse.subsystems.files.ftp,2.1.301.R33x_v201107212114,"org.eclipse.rse.subsystems.files.ftp",1383689525623 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1383691049381 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1383691049382 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1383691049382 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1383691049382 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383691049382 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1383691049382 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383691049382 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383691049382 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383691049382 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383691049382 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383691049382 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383691049382 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383691049382 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383691049382 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383691049382 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1383691049383 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1383691049383 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1383691049383 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1383691049383 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1383691049383 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1383691049383 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1383691049383 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1383691049383 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1383691049383 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1383691049383 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1383691049383 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1383691049383 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1383691049383 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1383691049383 -started,bundle,org.eclipse.ecf.filetransfer,5.0.0.v20110531-2218,"org.eclipse.ecf.filetransfer",1383691049383 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383691049383 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383691049383 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1383691049383 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1383691049383 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1383691049384 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1383691049384 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1383691049384 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1383691049384 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1383691049384 -started,bundle,org.eclipse.equinox.frameworkadmin,2.0.0.v20110815-1438,"org.eclipse.equinox.frameworkadmin",1383691049384 -started,bundle,org.eclipse.equinox.frameworkadmin.equinox,1.0.300.v20110815-1438,"org.eclipse.equinox.frameworkadmin.equinox",1383691049384 -started,bundle,org.eclipse.equinox.p2.artifact.repository,1.1.101.v20110815-1419,"org.eclipse.equinox.p2.artifact.repository",1383691049384 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1383691049384 -started,bundle,org.eclipse.equinox.p2.director,2.1.1.v20111126-0211,"org.eclipse.equinox.p2.director",1383691049385 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1383691049385 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1383691049385 -started,bundle,org.eclipse.equinox.p2.extensionlocation,1.2.100.v20110815-1419,"org.eclipse.equinox.p2.extensionlocation",1383691049385 -started,bundle,org.eclipse.equinox.p2.garbagecollector,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.garbagecollector",1383691049385 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1383691049385 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1383691049385 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1383691049385 -started,bundle,org.eclipse.equinox.p2.publisher,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.publisher",1383691049385 -started,bundle,org.eclipse.equinox.p2.publisher.eclipse,1.0.0.v20110815-1438,"org.eclipse.equinox.p2.publisher.eclipse",1383691049385 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1383691049385 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1383691049386 -started,bundle,org.eclipse.equinox.p2.touchpoint.eclipse,2.1.1.v20110815-1419,"org.eclipse.equinox.p2.touchpoint.eclipse",1383691049386 -started,bundle,org.eclipse.equinox.p2.touchpoint.natives,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.touchpoint.natives",1383691049386 -started,bundle,org.eclipse.equinox.p2.transport.ecf,1.0.0.v20111128-0624,"org.eclipse.equinox.p2.transport.ecf",1383691049386 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1383691049386 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1383691049386 -started,bundle,org.eclipse.equinox.p2.updatesite,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.updatesite",1383691049386 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1383691049386 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1383691049386 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1383691049386 -started,bundle,org.eclipse.equinox.simpleconfigurator.manipulator,2.0.0.v20110815-1438,"org.eclipse.equinox.simpleconfigurator.manipulator",1383691049386 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1383691049386 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1383691049386 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1383691049387 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1383691049387 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1383691049387 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383691049387 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1383691049387 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383691049387 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1383691049387 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383691049387 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1383691049387 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1383691049387 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1383691049387 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1383691049387 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383691049387 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1383691049387 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383691049387 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383691049387 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383691049387 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1383691049387 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1383691049387 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383691049387 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383691049387 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1383691049387 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1383691049387 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1383691049387 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1383691049388 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1383691049388 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1383691049388 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383691049388 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1383691049388 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1383691049388 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1383691049388 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1383691049388 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1383691049388 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1383691049388 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1383691049388 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1383691049388 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1383691049388 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1383691049388 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1383691049388 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1383691049388 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1383691049388 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1383691049388 -os,sysinfo,,,"linux",1383691049391 -arch,sysinfo,,,"x86",1383691049391 -ws,sysinfo,,,"gtk",1383691049391 -locale,sysinfo,,,"en_US",1383691049391 -processors,sysinfo,,,"8",1383691049391 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1383691049391 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1383691049391 -java.specification.name,sysinfo,,,"Java Platform API Specification",1383691049391 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383691049391 -java.specification.version,sysinfo,,,"1.6",1383691049391 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1383691049391 -java.version,sysinfo,,,"1.6.0_23",1383691049391 -java.vm.info,sysinfo,,,"mixed mode",1383691049391 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1383691049391 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1383691049391 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383691049391 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload11.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload11.csv deleted file mode 100644 index 059a29c..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload11.csv +++ /dev/null @@ -1,251 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -java.vm.specification.version,sysinfo,,,"1.0",1383691049391 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1383691049391 -java.vm.version,sysinfo,,,"19.0-b09",1383691049391 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383691049406 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691050558 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1383691053332 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691053345 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383691058965 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383691059448 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383691060512 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383691060551 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383691060554 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383691063339 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383691063339 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383691063340 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691063383 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691085200 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691090330 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691093038 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691097966 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691102125 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691105214 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691105566 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691107325 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691108028 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691108335 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691109121 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383691147233 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759870599 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759884717 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383759902972 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759902986 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383759928084 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383759934042 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759936299 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759936568 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759938555 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759939189 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759939489 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759940150 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383759940319 -opened,view,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views.PropertySheet",1383759940985 -activated,view,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views.PropertySheet",1383759940998 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.TaskList",1383759942471 -activated,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.TaskList",1383759942480 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383759943294 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383759944249 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383759949094 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383759949251 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383759973706 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383759974635 -started,bundle,org.eclipse.ui.views.properties.tabbed,3.5.200.v20110928-1505,"org.eclipse.ui.views.properties.tabbed",1383759974636 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759976705 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759977006 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759980009 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759980886 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759980927 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383759981625 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383759986768 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383759989762 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383760026195 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383760039361 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383760039374 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383760043020 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383760046340 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383760049872 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383760051006 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762020370 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762041694 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762069518 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762069533 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762071551 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762073647 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383762075063 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762075117 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1383762075275 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383762075279 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1383762075279 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1383762075279 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1383762075279 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1383762075279 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383762075279 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383762075279 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383762075279 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1383762075279 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1383762075279 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1383762075279 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1383762075280 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1383762075280 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1383762075280 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383762075280 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1383762075280 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1383762075280 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383762075280 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1383762075280 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383762075280 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1383762075280 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383762075280 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383762075281 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1383762075281 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383762075281 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1383762075281 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383762075281 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1383762075281 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383762075281 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383762075281 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383762075285 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383762075285 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383762075285 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.1.0.162,"com.altera.sbtgui.flash.plugin",1383762075285 -stopped,bundle,com.altera.sbtgui.gprof,13.1.0.162,"com.altera.sbtgui.gprof",1383762075285 -stopped,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1383762075285 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383762075287 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383762075288 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383762075288 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383762075288 -stopped,bundle,org.eclipse.equinox.p2.ui.sdk,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk",1383762075289 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1383762075289 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1383762075289 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1383762075289 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1383762075289 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1383762075289 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383762075293 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1383762075294 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383762075294 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383762075294 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383762075294 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1383762075294 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1383762075294 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383762075294 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383762075294 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383762075295 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383762075295 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1383762075295 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1383762075295 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383762075298 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1383762075298 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1383762075298 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1383762075298 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1383762075299 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1383762075299 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1383762075299 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1383762075299 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1383762075299 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1383762075299 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1383762088561 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1383762088562 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1383762088562 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1383762088563 -started,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383762088563 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383762088564 -started,bundle,org.eclipse.cdt.codan.core,2.0.0.201202111925,"org.eclipse.cdt.codan.core",1383762088564 -started,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383762088565 -started,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383762088565 -started,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383762088566 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383762088566 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383762088566 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383762088567 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383762088568 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383762088568 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383762088568 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1383762088568 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1383762088569 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1383762088569 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1383762088569 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1383762088570 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1383762088570 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1383762088570 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1383762088571 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1383762088571 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1383762088572 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1383762088572 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1383762088572 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1383762088573 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1383762088573 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383762088574 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383762088575 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1383762088575 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1383762088575 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1383762088576 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1383762088576 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1383762088577 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1383762088577 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1383762088577 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1383762088578 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1383762088578 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1383762088579 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1383762088579 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1383762088580 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1383762088580 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1383762088580 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1383762088581 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1383762088581 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1383762088581 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1383762088582 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1383762088582 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1383762088583 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1383762088583 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1383762088583 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1383762088584 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1383762088584 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1383762088585 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383762088585 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1383762088586 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383762088586 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1383762088587 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383762088587 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1383762088587 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1383762088587 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1383762088588 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1383762088588 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383762088589 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1383762088589 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383762088590 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383762088590 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383762088591 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1383762088591 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1383762088591 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383762088742 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383762088743 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1383762088744 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1383762088744 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1383762088744 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1383762088744 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1383762088745 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1383762088745 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383762088746 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1383762088746 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1383762088746 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1383762088747 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1383762088748 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1383762088748 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1383762088748 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1383762088749 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1383762088749 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1383762088749 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1383762088749 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1383762088750 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1383762088750 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1383762088750 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1383762088751 -os,sysinfo,,,"linux",1383762088753 -arch,sysinfo,,,"x86",1383762088753 -ws,sysinfo,,,"gtk",1383762088753 -locale,sysinfo,,,"en_US",1383762088753 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload12.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload12.csv deleted file mode 100644 index eafa029..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload12.csv +++ /dev/null @@ -1,251 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -processors,sysinfo,,,"8",1383762088753 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1383762088753 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1383762088753 -java.specification.name,sysinfo,,,"Java Platform API Specification",1383762088753 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383762088753 -java.specification.version,sysinfo,,,"1.6",1383762088753 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1383762088753 -java.version,sysinfo,,,"1.6.0_23",1383762088753 -java.vm.info,sysinfo,,,"mixed mode",1383762088753 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1383762088753 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1383762088753 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383762088753 -java.vm.specification.version,sysinfo,,,"1.0",1383762088753 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1383762088753 -java.vm.version,sysinfo,,,"19.0-b09",1383762088753 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1383762089041 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762096888 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762103872 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762103907 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762103917 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762110619 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762120294 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762121886 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762121897 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762126673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762192829 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762192841 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762194316 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762197601 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762197602 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383762197609 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762199494 -opened,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383762200760 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383762200792 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762200804 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383762202291 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762202325 -closed,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1383762202325 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762203118 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762203214 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762203244 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762203252 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762208847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762220726 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762220736 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762222776 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762222799 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762222799 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762223952 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762224013 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762224043 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762224051 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383762227543 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762235004 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762239590 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762239599 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383762243209 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383762243213 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383762243213 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383762243214 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762243289 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762243481 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762245790 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762246325 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762246926 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762247609 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762248333 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762248358 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762248358 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762249512 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762249536 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762249536 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762250223 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762250223 -opened,view,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.views.SearchView",1383762257481 -activated,view,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.views.SearchView",1383762257495 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762260802 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383762276966 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383762276969 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762278617 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762287465 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762287472 -activated,view,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search.ui.views.SearchView",1383762299059 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762308122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1383762320354 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762323268 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762323554 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762326013 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762326046 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762326058 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762335739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762345061 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762345072 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762363797 -started,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1383762422984 -started,bundle,org.eclipse.mylyn.wikitext.core,1.5.1.v20110720-0100,"org.eclipse.mylyn.wikitext.core",1383762423016 -started,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1383762527752 -started,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1383762527793 -started,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1383762527814 -started,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1383762527864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762561382 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762561394 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762563528 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762563538 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762573714 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383762575130 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762696130 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762699065 -executed,command,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.edit.opendecl",1383762701127 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762701160 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762701188 -executed,command,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.edit.opendecl",1383762711863 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762713883 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762713883 -executed,command,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.edit.opendecl",1383762716439 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762716471 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762716505 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762720706 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762720707 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762721465 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762721465 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762734824 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762760265 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762760273 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762773586 -started,bundle,org.eclipse.core.databinding,1.4.0.I20110111-0800,"org.eclipse.core.databinding",1383762775367 -started,bundle,org.eclipse.core.databinding.property,1.4.0.I20110222-0800,"org.eclipse.core.databinding.property",1383762775373 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383762775443 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.properties",1383762783280 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762783287 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762784542 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762786424 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762786453 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762786466 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762804235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383762807229 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383762811895 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762813454 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762814417 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762814458 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762815139 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383762821952 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383762826242 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762847174 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383762850359 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762897040 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762902340 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762968256 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762970248 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383762995536 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762995547 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383762999764 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763001072 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1383763001263 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383763001263 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1383763001264 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1383763001264 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1383763001264 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1383763001264 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1383763001264 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1383763001264 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1383763001264 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1383763001265 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1383763001265 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1383763001265 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1383763001266 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1383763001266 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1383763001267 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383763001267 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1383763001267 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1383763001268 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383763001268 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1383763001268 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383763001268 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1383763001269 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383763001269 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383763001269 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1383763001269 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383763001269 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1383763001269 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383763001269 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1383763001269 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383763001269 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383763001269 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383763001269 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383763001269 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1383763001269 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.1.0.162,"com.altera.sbtgui.flash.plugin",1383763001269 -stopped,bundle,com.altera.sbtgui.gprof,13.1.0.162,"com.altera.sbtgui.gprof",1383763001269 -stopped,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1383763001269 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383763001269 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383763001269 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383763001269 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383763001270 -stopped,bundle,org.eclipse.equinox.p2.ui.sdk,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk",1383763001270 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1383763001271 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1383763001271 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1383763001271 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1383763001272 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1383763001272 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383763001273 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1383763001273 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383763001273 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383763001273 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383763001273 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383763001273 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1383763001274 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1383763001274 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1383763001275 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383763001275 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1383763001275 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1383763001275 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383763001275 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383763001275 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383763001275 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383763001276 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1383763001276 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1383763001276 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383763001278 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1383763001278 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1383763001278 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1383763001278 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1383763001279 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1383763001279 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1383763001280 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1383763012813 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1383763012814 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1383763012814 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1383763012815 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1383763012815 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1383763012815 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1383763012816 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1383763012816 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1383763012817 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1383763012817 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1383763012817 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1383763012817 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1383763012818 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1383763012818 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1383763012818 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1383763012819 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1383763012819 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1383763012819 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1383763012819 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1383763012820 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1383763012820 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1383763012820 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1383763012821 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1383763012821 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1383763012821 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload13.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload13.csv deleted file mode 100644 index f8396f1..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload13.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1383763012822 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1383763012823 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1383763012823 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1383763012823 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1383763012823 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1383763012824 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1383763012824 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1383763012824 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1383763012825 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1383763012825 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1383763012825 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1383763012826 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1383763012826 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1383763012826 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1383763012826 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1383763012827 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1383763012827 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1383763012827 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1383763012828 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1383763012828 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1383763012828 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1383763012829 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1383763012829 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1383763012829 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1383763012830 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1383763012830 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1383763012831 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1383763012831 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1383763012832 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1383763012832 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1383763012832 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1383763012833 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1383763012833 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1383763012833 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1383763012834 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1383763012834 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1383763012834 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1383763012835 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1383763012835 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1383763012836 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1383763012836 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1383763012837 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1383763012837 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1383763012838 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1383763012838 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1383763012839 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1383763012839 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1383763012839 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1383763012840 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1383763012840 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1383763012841 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1383763012841 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1383763012841 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1383763012842 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1383763012842 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1383763012842 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1383763012843 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1383763012843 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1383763012843 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1383763012844 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1383763012844 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1383763012844 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1383763012844 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1383763012845 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1383763012845 -os,sysinfo,,,"linux",1383763012847 -arch,sysinfo,,,"x86",1383763012847 -ws,sysinfo,,,"gtk",1383763012847 -locale,sysinfo,,,"en_US",1383763012847 -processors,sysinfo,,,"8",1383763012847 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1383763012847 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1383763012847 -java.specification.name,sysinfo,,,"Java Platform API Specification",1383763012847 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383763012847 -java.specification.version,sysinfo,,,"1.6",1383763012847 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1383763012847 -java.version,sysinfo,,,"1.6.0_23",1383763012847 -java.vm.info,sysinfo,,,"mixed mode",1383763012847 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1383763012847 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1383763012847 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1383763012847 -java.vm.specification.version,sysinfo,,,"1.0",1383763012847 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1383763012847 -java.vm.version,sysinfo,,,"19.0-b09",1383763012847 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1383763014037 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1383763017078 -started,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1383763017107 -started,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1383763017109 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763017163 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763017210 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763018865 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763018866 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1383763018873 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763021489 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1383763021965 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763023404 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763023939 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763027479 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763045433 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763049143 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763049344 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763050858 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763051067 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763053194 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763060335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763064142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763069558 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763070346 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763070535 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763070735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763070926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763071605 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763085069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763087632 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763089343 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763089535 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763089719 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763089879 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763090446 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763092676 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763094712 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763095137 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763109352 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763112436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763123598 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383763123997 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763132263 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763132430 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763132574 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763140845 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763142523 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763144055 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763144392 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763170069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763173256 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763174419 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763175804 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763176041 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763179540 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763180224 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763180414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763181183 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763189426 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763190593 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763190957 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1383763191495 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1383763191496 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1383763191497 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763191542 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763192211 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763195209 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763195501 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763196905 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763197506 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763197806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763198515 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763211191 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763256979 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763259713 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763264494 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763264661 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763266566 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763266726 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763268071 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763271486 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763272751 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763273101 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763279167 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763279982 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763303351 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763304861 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763306446 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763306825 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763310486 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763310696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763330354 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763331895 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763333117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763333503 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383763339395 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763339618 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763339649 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763342162 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763342162 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763352995 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763359267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763361243 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763362597 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763454954 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763627859 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763632745 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763634839 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763636412 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763644172 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763698086 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.goto.lineEnd",1383763710985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763712548 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763714843 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763715388 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763730420 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763734686 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763734721 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383763734730 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763735572 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1383763736558 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763736565 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763762732 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763767137 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383763768685 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763769620 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763772753 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763787168 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383763792864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763794198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763794826 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763797796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763800024 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763809391 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763820015 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763827857 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763829002 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383763882815 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763884843 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763896424 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763902488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383763920047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763920739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763920921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763921073 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763921241 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763921393 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763921553 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763925351 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763928858 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383763930801 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763931736 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763944057 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383763947320 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763950258 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383763954286 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383763985289 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383763993205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764008241 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764008793 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764009041 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764009273 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764009704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764010000 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764012031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764016202 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764018513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764018720 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764018896 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764019064 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764019360 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764019544 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764019712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764019912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764020241 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764020440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764026654 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764027567 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764035991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383764038215 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764046123 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764047429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383764054514 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764055662 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764087096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764089689 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764139720 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764139904 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764140055 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764140215 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764140376 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload14.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload14.csv deleted file mode 100644 index fcf53b7..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload14.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764140527 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383764174806 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383764175483 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383764176187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764180934 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764182574 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764183016 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764185021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764189842 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764190007 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764190167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764190319 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764191975 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764194080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764194254 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764194414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764194566 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764199117 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764200744 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764200911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764201070 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764201223 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764202413 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764212567 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764212742 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764212895 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764213038 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764214493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764254807 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764254999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764255159 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764255326 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764255486 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764255663 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764255862 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764258783 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383764259247 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383764275369 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383764275437 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383764275446 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383764276095 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383764285582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764309350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764329091 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764562922 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764619694 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764622899 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764625100 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764641804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383764664315 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383764665405 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765439283 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765468985 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765617429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765624891 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765658822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765661983 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765663086 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765665988 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765680461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765692236 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765737395 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765746546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765747757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765748125 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765748461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765748644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765748821 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765748964 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765749133 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765749293 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765749444 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765750856 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765751268 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383765759509 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765760209 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765786563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765819220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383765826530 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765829337 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765831794 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765836921 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383765839558 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765841885 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765843465 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765844263 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765844839 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765845526 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765845844 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765936677 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765938948 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383765939978 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383765961210 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765966737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765967317 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765971584 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765972250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383765979097 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765981599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383765983524 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383765983866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383765998979 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766001113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766002333 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766015564 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766020010 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766022474 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766028398 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766029018 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766038379 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766041620 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383766044864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766048519 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766049019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766049537 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766065135 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766065847 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766066464 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766382669 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766393783 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766397832 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766414276 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766415078 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766415561 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766417057 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766418214 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766449848 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766450016 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766450192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766454174 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766454923 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766456719 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766472630 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766481137 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766487769 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766519565 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766576174 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766598479 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766664395 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383766692645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766696448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383766697892 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383766708137 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766713339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766731484 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766735471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766735645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766736462 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766757821 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766792084 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766813099 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766814682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766819304 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766825710 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766842872 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383766876211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383766880350 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383766889221 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383766889509 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383766889860 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383766890147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383766890478 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.redo",1383766897880 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.redo",1383766898092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.redo",1383766898268 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.redo",1383766898437 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.redo",1383766898619 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766930659 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383766960455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383766965919 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766966450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766969496 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766969908 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766971249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383766972568 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383766973242 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383766975748 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766980664 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766993259 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766997140 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383766999624 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767003015 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767008136 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767013116 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767013413 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767014896 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767015148 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383767022526 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767027186 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383767029531 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767030763 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767030983 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383767038921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767042990 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767045754 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767061762 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383767063276 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767064705 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767065424 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767065727 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767066430 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383767068101 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767110667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767110843 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767111003 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767111147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383767111299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767115090 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383767121122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383767123343 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767128408 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767147658 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383767150273 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383767153142 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767154249 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767154667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767171746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767171907 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767182811 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767186034 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383767186049 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383767187166 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768904748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383768913119 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768915220 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768940209 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768945118 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768967453 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383768980175 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769015717 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769016712 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769023529 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769026214 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769102821 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769112212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769626227 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383769635498 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383769637369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769638760 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769639234 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383769651905 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769658848 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769665244 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769669774 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769896139 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383769900562 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770014877 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770026539 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770238991 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770298519 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770346060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383770357900 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383770363222 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770364658 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770365073 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383770388228 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383770411204 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383770412839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770414399 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770414826 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770417000 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770447886 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383770447908 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770452631 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770453535 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770458171 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770550061 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383770579333 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770595558 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770624530 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770629415 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770632035 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770635822 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770640859 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770643229 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload15.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload15.csv deleted file mode 100644 index db7fc93..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload15.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770643539 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770645366 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770646077 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770646380 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770647080 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770647476 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770658648 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383770658667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770670997 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770673463 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383770680374 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771036964 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771062314 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771064145 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771065640 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771066065 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771067365 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771103245 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771103265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771130990 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771132734 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771134204 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771134626 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771135522 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771176237 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771176256 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771176795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771176992 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771178585 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771179901 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771181917 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771182334 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771183274 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771252674 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771252692 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771272165 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771273783 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771275363 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771275779 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771277002 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771368078 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771370027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383771375244 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383771377234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771378338 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771378570 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771380020 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771381424 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771381838 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771382547 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771691549 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771698969 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771725109 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771725292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771725612 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771728113 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771739495 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771776682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771777645 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771778419 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771779334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771833705 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771848318 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771849716 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771850141 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771850728 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771899736 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383771899752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771901359 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771904645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771904966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771906438 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771907285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771909834 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771912767 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383771913122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383771913683 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383771915096 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771917481 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771917900 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383771919254 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772088361 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383772100486 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772178001 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383772183784 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772185355 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772185765 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772186666 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772218156 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383772218175 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383772219083 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772234049 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383772261601 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772263164 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772263621 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772264670 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772316009 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383772316027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772319879 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383772321422 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772323000 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772323418 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772324598 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772420006 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383772420025 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.toggleOverwrite",1383772458685 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383772458711 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.toggleOverwrite",1383772459301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772460751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383772499661 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383772505217 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772514919 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383772525224 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383772531102 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772533792 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772534249 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383772539177 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773421339 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383773436522 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383773437798 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773443432 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773722029 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773723401 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773725124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383773743525 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773745838 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773759972 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383773762142 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773763621 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773764038 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773764483 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773765138 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773765505 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773789340 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773793425 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773793584 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773794428 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773935988 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383773936010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383773937369 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383773938283 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383773946861 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383773952917 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773954634 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773955049 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773963776 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773963932 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383773965014 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383774159837 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383774181396 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383775679042 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383775683265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383775684696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383775685873 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383775688843 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383775689278 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383775701066 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383775702575 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383775704089 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383775704516 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383775706272 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853082317 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383853094841 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853117847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853119847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853131799 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853134011 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853145567 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853158230 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383853250646 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853252484 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853292262 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853294505 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853296138 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853302565 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853313807 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853315320 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853315450 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853316156 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853323454 -activated,view,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console.ConsoleView",1383853323462 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853326639 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853330104 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853332714 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853334963 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853335570 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853336469 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853368009 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383853368032 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853369548 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853370786 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853577409 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853577423 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853580305 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853580709 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853583033 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853687839 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383853687862 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853706795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853708691 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853716931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383853719349 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853721949 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383853725280 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853725798 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853729883 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853731868 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853732157 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853762607 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383853762724 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853762733 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383853780009 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383853789499 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383853792150 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383853822205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383853822364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383853822508 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383853822652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383853823181 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383853825344 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853826945 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853827353 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383853828815 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383856691031 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1383856691059 -error,log,,,"Unhandled event loop exception",1383856691192 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383856696155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383856701550 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383856702234 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383856702839 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857321570 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857323070 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857329405 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857330052 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857539628 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857540287 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857547714 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857571455 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857737678 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383857752947 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857773442 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857773478 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383857773486 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857794091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383857795512 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857797243 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383857800428 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383857802731 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383857804372 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857808539 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857808763 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857810245 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383857819560 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383857820852 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857822106 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857823058 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857823112 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857823837 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383857825348 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383857830500 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857831713 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857831869 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383857832776 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383858928770 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383858966727 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383858970227 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383858973722 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383859051473 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383859743849 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383859757386 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383859788011 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383859792130 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935875994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383935884835 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383935886260 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload16.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload16.csv deleted file mode 100644 index c78d7d7..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload16.csv +++ /dev/null @@ -1,301 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935887448 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935887529 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935894751 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935897403 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935901967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935904612 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935907540 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935910167 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935913792 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935930000 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935933385 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935933700 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935935335 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935936044 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935936358 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935937053 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935937813 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935938373 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383935938891 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383936190803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383936193703 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941693777 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383941696248 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383941702336 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383941702502 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383941702856 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383941704800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941705862 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941706016 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941713159 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941715800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941717968 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941718390 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941720885 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941721602 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383941722362 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942768392 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383942779485 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383942780626 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383942780767 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383942782314 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383942790130 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383942792978 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942794911 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942795304 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942797584 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942892434 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383942903650 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383942924688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383942924831 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383942926368 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383942928824 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942930536 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942930986 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383942931946 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383951656431 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383951657560 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955679397 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955682781 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955682930 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955688370 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955691054 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955693604 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955693664 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955698269 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955698644 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955700727 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955701475 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955701778 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955702498 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383955723278 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383955730581 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383955732373 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955733766 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955734181 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955738721 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955739375 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383955739861 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383991316394 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383991316842 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383991972139 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383991977217 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000190559 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384000210639 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000243440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000260597 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000266136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000266350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000274492 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000276242 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000279711 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1384000288213 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000290385 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000290987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1384000292810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000305734 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000305885 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000312166 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000312318 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1384000317328 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000317905 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1384000320874 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000321326 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384000322948 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000324631 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000325034 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000326155 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384000610294 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384000631956 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1384000704518 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000705437 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1384000707406 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000730082 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000806475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000892569 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000920837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000938595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000947632 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000984292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384000994667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384000998631 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1384001003383 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1384001005978 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001009497 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001010766 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001064758 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001083149 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001089968 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001090797 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384001136877 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001138350 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001138799 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001139555 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001167638 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384001167659 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001172319 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001187010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001187696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001187951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001188127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001188303 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001188471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001188887 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001189376 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001189864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001190127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001190663 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001190847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001191007 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001191183 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001191567 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001198447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001198583 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1384001198727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001199335 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384001200741 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001202215 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001202629 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001216227 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001218524 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001219479 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001277408 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001278521 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001297743 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001300010 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001300226 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001302991 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001336283 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384001359232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384001401015 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384001403474 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001405422 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001405832 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384001406880 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384005941711 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384005976601 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384005977697 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384005979000 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384014694046 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384014696735 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384014696885 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384014698401 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384026264860 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384026266409 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035182058 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384035183923 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384035219879 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384035221756 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035223578 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035223669 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035228483 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035231271 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035233495 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035233916 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384035235022 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384088365703 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384088369193 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384536764540 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384536765650 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545738220 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545753210 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545753672 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545754109 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545759568 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545761107 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545761592 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545762291 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384545994033 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384545999018 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546103384 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546104121 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546104820 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546105493 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546107783 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546109999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546111035 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546398775 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546418049 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546463819 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546487716 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546488284 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546488689 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546489509 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384546490556 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616448669 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616450544 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616450996 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616451820 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616875974 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616876706 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616937975 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384616939933 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618219419 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618220654 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618221010 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618232267 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618245770 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618249004 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618250004 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618251224 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618251931 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618254986 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618264202 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618272732 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618340230 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618340950 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618389254 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618510605 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618511151 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618511974 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618821295 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618839088 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618839517 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384618839934 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384632292975 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384632293875 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634761257 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634782171 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634926973 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634934411 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634935053 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384634936012 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384638476852 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384638499946 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384731073492 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384731094634 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804760024 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1384804798311 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384804814285 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804815523 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804815666 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804822561 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804825388 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804827129 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804830693 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804832674 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804833140 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384804835319 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805240590 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805247371 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805247518 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1384805250050 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805265282 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1384805267040 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805267052 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805269434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1384805270481 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805270492 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805271984 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805272838 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384805274902 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809980566 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1384809982127 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809985766 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809985853 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809989333 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809991997 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809993833 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809997353 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384809999741 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload17.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload17.csv deleted file mode 100644 index 8e70a82..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload17.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384810000210 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384810001762 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812644756 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812647236 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812647343 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812652601 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812655235 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812662684 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812662715 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812665694 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812665855 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812671422 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812676490 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812678585 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812678797 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1384812680290 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385062558614 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385062559485 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385210003400 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385210004093 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385221036719 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385221037588 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232432870 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385232445114 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232466557 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232467690 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385232473188 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232477231 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232479970 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232482052 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232482186 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385232487072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385232499147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385232502339 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385232505402 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232506844 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232507297 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232512050 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232550694 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232551217 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232551703 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385232560174 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385233759950 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385233760484 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385248784896 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385248785439 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385248841228 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385248842064 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385255285762 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385255287429 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385255450366 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385255456737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385255459933 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385255461600 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317028645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317105011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317109921 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317111932 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317113117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317113262 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317118020 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317120666 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317122834 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317123038 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317129048 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317133170 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317134460 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317136096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317136530 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317137106 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317137802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317140022 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317181806 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317185545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317189001 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317191035 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317192527 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317192978 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317194037 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317221010 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317221025 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317225059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317225234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317228930 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317229069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317239490 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317239626 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317240753 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317242246 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317243826 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317244230 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317245076 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317245464 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317245841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317261955 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317261977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317268832 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317270634 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317271892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317272251 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317274858 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317365353 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317365374 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317381855 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317384827 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317386326 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317386677 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317387165 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317423579 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317423602 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317439983 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317440894 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317442463 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317443891 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317444246 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317444812 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317445346 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317445754 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317528200 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317530135 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385317531846 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385317533075 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317536198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317538273 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317538671 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317542902 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317544368 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317544725 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317545167 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317555479 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317574316 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317575502 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317577835 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317580487 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317581596 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317584016 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317585613 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317586719 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317587076 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317588243 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317631969 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317631986 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317633164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317634049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317637741 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317638120 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317641421 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317649095 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317654054 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317655498 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317655856 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317656662 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317657104 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317657490 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317665089 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385317665110 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317665649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385317665774 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385317666583 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385317667809 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317669287 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317669641 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317670472 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317670967 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385317671685 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319390087 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385319480849 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385319484327 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385319484868 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.goto.lineStart",1385319485182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385319541577 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385319543982 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385319580625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385319581181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385319587438 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385319592257 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385319593493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385319635744 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385319636302 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385319640554 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385319650488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385319653691 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385319655671 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319657088 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319657439 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319658941 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319659436 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319659955 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319769772 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385319769797 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385319776661 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385320979072 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385320980286 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321012377 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321192549 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321265753 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321266759 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321267904 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321270898 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321277036 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321298662 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321321038 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385321325709 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321328211 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321337173 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385321338306 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321338998 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385321344187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385321345771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385321347810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321359276 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321381917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385321400588 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385321401114 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385321401368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321411582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321429895 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321459483 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385321477970 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321479330 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321479689 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385321481242 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321524077 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321524786 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321526920 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321532810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321554251 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321603331 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321612322 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321620811 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321709900 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321766674 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385321776331 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321777744 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321778160 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321779746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321780531 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321782108 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385321861778 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385321922362 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321929858 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385321939578 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385322004128 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385322006555 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322118084 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322154774 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322239724 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322274489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385322309648 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385322316246 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385322346757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385322349002 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322390652 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322398097 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385322406583 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322573263 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322573852 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322580426 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322580858 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322582519 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322583068 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322583933 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322584398 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385322584739 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323839826 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323850523 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323851009 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323851423 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323852234 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323855268 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323856485 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323858620 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323940827 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385323974002 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323976239 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload18.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload18.csv deleted file mode 100644 index f8d867c..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload18.csv +++ /dev/null @@ -1,301 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323978599 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385323999905 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385324000516 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385324003800 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325159104 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325159396 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325159731 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325160728 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325174440 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325175421 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325176106 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325181287 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325223149 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325226499 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325324989 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325325994 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325610235 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325612874 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325674319 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325677723 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325698489 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325701578 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325718753 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325720479 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325723802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325727043 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325727830 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325728091 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325820995 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385325822825 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326174627 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326177724 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326428199 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326433758 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326867215 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385326870616 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328498593 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328499998 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328500437 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328501045 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328516127 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328517067 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328517746 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328518828 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328519745 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328521487 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328528679 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328530491 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328535750 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385328536922 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329074556 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329076202 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329089067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329101031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329163937 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329164113 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329164273 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329164449 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329171618 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329172859 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329176482 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329177383 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329213631 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385329221999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329225194 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329225376 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329225715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329226096 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385329250943 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329254298 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329254906 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329258761 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329259033 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329262335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329270865 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329272220 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329273788 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329274202 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329275855 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329276803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329277134 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329360655 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329360673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329376548 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329377587 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329377899 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329386178 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329388752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329398477 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329406641 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329408001 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329409012 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329433070 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329444957 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329467740 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329469141 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329470666 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329470879 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329473650 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329475312 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329475519 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329476233 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329476478 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329478032 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329479092 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329480000 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329480042 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329480967 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329481281 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329492170 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329492186 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329498537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329498751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329504063 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329506183 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329508365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329510488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329511479 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329512076 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329513506 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329514707 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329515112 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329515762 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329618065 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329620246 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329626731 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329628499 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329630323 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329635691 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329637384 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329640283 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329641102 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329662947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329666911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385329699140 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329702016 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329702286 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329755860 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329765358 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329777436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385329786603 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329788545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329789364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329790712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329804165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329804420 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329804596 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329804748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329804916 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329816644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329833540 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329834422 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329834730 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329836606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329837849 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329838255 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329839278 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329864002 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329864024 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329874142 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329878346 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329878740 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329879225 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329881202 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385329881215 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329883284 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329883646 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329884637 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385329918583 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385329918600 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329941057 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329949569 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329961352 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329963984 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329966847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329970839 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385329975551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385329985557 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385329991010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385329999561 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330000488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330005287 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330006182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330006750 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330007326 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330007716 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330022475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330035313 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330048168 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330049884 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330095402 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330098616 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330100490 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330106960 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330119986 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330122075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330125717 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330126804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330130080 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330130779 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330133078 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330135223 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330136676 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330161473 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330162827 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330177598 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330179649 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330181266 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330194089 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330205106 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330206460 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330207155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330208157 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330209774 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330216304 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330256744 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330265870 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330275670 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330276407 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330295576 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330301880 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330304046 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330305274 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330319794 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330322650 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330341329 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330343292 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330349795 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330350898 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330355098 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330355952 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330360119 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385330395625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330397562 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330397880 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385330399767 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330402699 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330405879 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330414078 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330421769 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330422967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330433347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330471231 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330495422 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385330504852 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330505779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330523056 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330530814 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330541022 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330541414 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330544023 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330544366 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330552541 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330552872 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330560703 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330583197 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330637900 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330645796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330669924 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330689478 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330756180 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330809181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330820147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385330828475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330832144 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330832804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330834790 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330834966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330835253 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330838515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330895269 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330895806 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330901693 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330902596 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330903734 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330912966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330924747 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385330932139 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385330934880 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330936989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330937140 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330937292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330937436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330942740 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385330945181 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330947022 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330947230 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385330952680 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330953838 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330955365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330956917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330958965 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330960251 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385330962922 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330964231 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330964436 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385330975444 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330977004 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330981934 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330983573 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload19.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload19.csv deleted file mode 100644 index 0c8e365..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload19.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330985005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330985348 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385330986683 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330988008 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385330988198 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385330994634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385330998138 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385330999526 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331000082 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331001333 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331002819 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331003020 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331011696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331015915 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331017252 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331018462 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331019155 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331019465 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331020298 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331025446 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331037424 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331037442 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331043106 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331063795 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331068996 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331070332 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331070741 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331071366 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331115499 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331115517 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331116853 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331132397 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331186239 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331445090 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331525655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331578623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385331851591 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331890404 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331890506 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331890514 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331890985 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331915115 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331930902 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331935060 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331939903 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331939974 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331939982 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331942249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385331943172 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331945527 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331945574 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331945582 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385331948311 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385331949040 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385331951854 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385331955143 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331956676 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331957088 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385331958084 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332015430 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385332015445 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332021619 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385332022918 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332024101 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332024509 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332025110 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332191217 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385332191232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385332204225 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385332204822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332205442 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385332208418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385332209680 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332226649 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385332228007 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332229243 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332229655 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332230681 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332574782 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385332579357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332584375 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332594412 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385332598954 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385332600128 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332601290 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332601691 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332603756 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332604723 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385332605242 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333029699 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385333029715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333052380 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333057149 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333061892 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333063861 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333074010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333092221 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333127271 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333287687 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333288783 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333291063 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333340789 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333345755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333349570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333352853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333424473 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333428945 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333431614 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385333465802 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385333468057 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385333471565 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385333474370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385333476364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333486170 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333495109 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333495259 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333495411 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333495579 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333496956 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333497265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385333503370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385333505265 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385333507831 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333510611 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333510771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333510907 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333511067 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333511595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333514844 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333519145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333523905 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385333537920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333538657 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333540665 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385333543822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385333599510 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333600288 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333600538 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385333602813 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333603451 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333643285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333652515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385333652690 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333654115 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333659690 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333716204 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333729305 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1385333730459 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333730466 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333733713 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1385333734866 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333734873 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333743478 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333746282 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333840448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385333858839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333901776 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385333902964 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334052278 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334114045 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334147374 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334149529 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334155181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334197726 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334203725 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334213206 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334292095 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334295675 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385334299076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385334300115 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334303454 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334303637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334303822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334303949 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304610 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304689 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304729 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304810 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334304850 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334305013 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334305198 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334305374 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334305798 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334327692 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385334338188 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334339311 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334340061 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385334344496 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334354288 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334365727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334377185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334395200 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334406259 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334413122 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334414419 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334414837 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334416780 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334434330 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334434352 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334454061 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334455595 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334456765 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334457181 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334457828 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334486123 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334486142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334491454 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334491628 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334491796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334491972 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334494293 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334495997 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334497603 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334498021 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334498679 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334600730 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334600749 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334615398 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334615748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334629714 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334632108 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334633479 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334633879 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334634927 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334692220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334692499 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334692667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334692818 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334693155 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334693339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334693507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334712476 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334712635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334712795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334714607 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334763766 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334776794 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334793354 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334798386 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334800885 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334801297 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334808311 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334903394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334903569 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334903721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334904034 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385334905066 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334905842 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334929009 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334931746 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334933219 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334933632 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334936261 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334982169 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385334982188 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385334987311 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385334988981 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334990509 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334990917 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385334991341 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335073094 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385335073115 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335074487 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385335075969 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335077415 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335077811 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335079186 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335119573 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385335119592 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335126664 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335158673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335168128 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335169937 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv deleted file mode 100644 index e122277..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload2.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435193680 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435207293 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435209453 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435214132 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435218202 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435229634 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435235519 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435238644 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435256140 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435257188 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435258213 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435268216 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435269716 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435273047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435290157 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435295291 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435300362 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435301765 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435302506 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435303534 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435312279 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435318305 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435322201 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435333054 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435334777 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435336036 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435369973 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435370149 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435370317 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435370485 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435370653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435371469 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435372853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435382570 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435383948 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435483878 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435487527 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435489436 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435493361 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435494771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435497157 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435621683 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435621866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435622042 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435629035 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435629219 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435630220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435661819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435661962 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435670299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435670459 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435678403 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435678586 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435678747 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435683339 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435695575 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435701626 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435701805 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435701954 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435702218 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435703133 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435727820 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435733957 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435740254 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435745310 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435746020 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435758354 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435762809 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435765189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435773169 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435780478 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435783572 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435788866 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435791872 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435796450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435802434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383435802585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435804079 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435806609 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435812304 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435816326 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435817199 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435821637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383435833319 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383435913746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436143546 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436158493 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436203046 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436205892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436206533 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436207117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436718968 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436728888 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436768924 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436785959 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436788320 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436814896 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436829600 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436832896 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436857319 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436866609 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436875128 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436875893 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436880357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436887330 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436887998 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436891988 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436900880 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436901528 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436904984 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436914911 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436915659 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436922126 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436931455 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436932255 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436955868 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436973001 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383436978395 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.select.lineEnd",1383436991880 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383436992272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383436992715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383436995185 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437001961 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437520715 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437522591 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437525004 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437528871 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437543232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437553372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437554751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437555999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437557214 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437558455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437559663 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437561119 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437562327 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.scroll.lineDown",1383437562365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437563991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437565176 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.scroll.lineDown",1383437565220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437566623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437568063 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437569127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437570151 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437571351 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437572590 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437589886 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437592849 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437594255 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.scroll.lineDown",1383437594310 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437595631 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437597047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437598239 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437599423 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437600599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437601775 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.scroll.lineDown",1383437601828 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437603215 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437603666 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437615327 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437621324 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437624468 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437632299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437658996 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437659601 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383437661189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383437663469 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437664154 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437667741 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437676833 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437690595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437691193 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437691465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437691873 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437692146 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437692409 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437692681 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437692962 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437693338 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437704936 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437711985 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437713326 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437718932 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437724331 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437725542 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383437729683 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383437730050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437730707 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383437744853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437750440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437761384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437764017 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437766469 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437798370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437809277 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437820953 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437830312 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437851318 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437854531 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437891913 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437904186 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437906237 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437911065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437911647 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383437913387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383437915782 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437916629 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437919293 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437930405 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437942389 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437944885 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437962596 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437975513 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437977443 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383437983086 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437985809 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437988395 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383437995769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383437998665 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383437999981 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438004804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438005458 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438008096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438020926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383438027080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383438028261 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438040586 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438043511 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438217575 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438219522 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438229499 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438241502 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438244032 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438253349 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438259660 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383438268703 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.scroll.lineDown",1383438268770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383438269788 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438271617 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438273960 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438274534 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438276471 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438305263 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438314242 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438324661 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383438327223 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383438327803 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438329336 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438337122 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438341106 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438350311 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438351148 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438357564 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383438370238 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383438371803 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383438372475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438374912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438376141 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438377704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438417637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438422122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438422575 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438423616 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438423943 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438424800 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438425023 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438425656 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383438425823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438426581 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383438435525 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438442445 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438443565 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438454466 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438456148 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438457040 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload20.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload20.csv deleted file mode 100644 index 1190219..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload20.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335184192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335187678 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335205560 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335225619 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335282276 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385335289476 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335292723 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335293926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335296597 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335332288 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385335334056 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335335569 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335335979 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385335338687 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335345051 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385335346487 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335348065 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335348467 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335348889 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335349310 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335349914 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335415165 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385335415185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335434686 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335447919 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335464054 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335544460 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335547961 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335548673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335562533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335589350 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335661674 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335683987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335684501 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335689625 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335689808 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335697030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335701388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335725060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335745475 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335760639 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335763315 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385335765827 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335770258 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335772201 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335772580 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335773301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335773883 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335779332 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335779942 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335786898 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335792850 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335795272 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385335798406 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335868913 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335871922 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335873917 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335874914 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335894299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335903569 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385335905813 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335906929 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385335907340 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385335910826 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335917282 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335919639 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335926195 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385335933811 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335937921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335948665 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335950789 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335956985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385335959030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385335984443 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385335995697 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336007357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336010209 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336027792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336029595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336037464 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336043950 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336047418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336047601 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336047761 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336047937 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336051450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336058683 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336066010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336071882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336078240 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336081133 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336090319 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336094274 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336094530 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336100386 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336104666 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336106258 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336107636 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336108044 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336111068 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336221200 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336221219 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336235771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336235928 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336236088 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336238091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336241183 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1385336241444 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336241451 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336244985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336253447 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336262934 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336286145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336288517 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336291503 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336292985 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336293393 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336296197 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336331695 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336331714 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336390537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336394855 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336418257 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336433809 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385336438890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336453653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336458455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336459687 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336464566 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336470813 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336472792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336480325 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336483850 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336487926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336490960 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336491709 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336497168 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336500132 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336511676 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336514216 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336514536 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336526485 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336528781 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336531825 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336532093 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336542838 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336545367 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336545645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336557021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336559583 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336559845 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336573533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336575533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336579000 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336581577 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336581846 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336584783 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336585061 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336592436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336602288 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336606967 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336608644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336612672 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336614494 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336618373 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336627398 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336634071 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336642500 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336646765 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336661640 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336665444 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336667599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336670647 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336674102 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336676159 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336680371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336682199 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336682758 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336685893 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336688088 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336689564 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336693365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336695145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336695651 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336698441 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336700534 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336702348 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336704642 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336705031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336716174 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336718363 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336719605 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336719805 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336724054 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336725901 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336727588 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336728943 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336729680 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336729994 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336730869 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336731205 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336751633 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336751652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336766244 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336768315 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336768622 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336771677 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336774390 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336778749 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336780877 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336782741 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336783123 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336791989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336798606 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336804390 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336804525 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336814766 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336818866 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336820974 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336822164 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336822569 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336823826 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336863464 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336863485 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385336883659 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336884622 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336884938 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336885237 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336885705 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336890350 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336890755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385336895011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336897008 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336899189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385336899332 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336900023 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336903070 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336904380 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336904822 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336905187 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336951357 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385336951376 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385336966783 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336972813 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385336982252 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385336983877 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336985012 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336985417 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385336985881 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337027905 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385337027924 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337043228 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337045704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337058359 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337059099 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337072961 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337075206 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337120618 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385337133536 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337135091 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337135541 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337136678 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337179237 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385337179260 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337198394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385337208240 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385337212688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385337214055 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337221764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337221945 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337228299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337228434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337238064 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385337249920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337251969 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload21.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload21.csv deleted file mode 100644 index e6a37cb..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload21.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337257737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385337258619 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337258975 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337272874 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385337276250 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337277462 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337277922 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337278409 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337338018 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385337338034 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337341675 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385337342769 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337344047 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337344501 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337345234 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337394568 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385337394592 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337410758 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337412105 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337412455 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337437909 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385337449121 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385337456647 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337457887 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385337458335 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1385851355016 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1385851355017 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1385851355017 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1385851355018 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1385851355018 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1385851355018 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1385851355019 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1385851355020 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1385851355020 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1385851355020 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1385851355020 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1385851355020 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1385851355021 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1385851355021 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1385851355021 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1385851355022 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1385851355022 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1385851355022 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1385851355023 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1385851355023 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1385851355023 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1385851355024 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1385851355024 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1385851355025 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1385851355025 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1385851355026 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1385851355027 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1385851355027 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1385851355027 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1385851355027 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1385851355028 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1385851355028 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1385851355029 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1385851355029 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1385851355030 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1385851355030 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1385851355030 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1385851355031 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1385851355031 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1385851355031 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1385851355032 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1385851355032 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1385851355033 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1385851355033 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1385851355033 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1385851355033 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1385851355034 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1385851355034 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1385851355035 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1385851355035 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1385851355036 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1385851355036 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1385851355037 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1385851355037 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1385851355038 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1385851355038 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1385851355038 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1385851355038 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1385851355039 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1385851355039 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1385851355040 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1385851355040 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1385851355041 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1385851355041 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1385851355042 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1385851355042 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1385851355042 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1385851355043 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1385851355044 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1385851355044 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1385851355045 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1385851355045 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1385851355045 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1385851355046 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1385851355047 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1385851355047 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1385851355048 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1385851355048 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1385851355049 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1385851355049 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1385851355049 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1385851355050 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1385851355051 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1385851355051 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1385851355052 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1385851355052 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1385851355053 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1385851355053 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1385851355053 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1385851355053 -os,sysinfo,,,"linux",1385851355055 -arch,sysinfo,,,"x86",1385851355055 -ws,sysinfo,,,"gtk",1385851355055 -locale,sysinfo,,,"en_US",1385851355055 -processors,sysinfo,,,"8",1385851355056 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1385851355056 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1385851355056 -java.specification.name,sysinfo,,,"Java Platform API Specification",1385851355056 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1385851355056 -java.specification.version,sysinfo,,,"1.6",1385851355056 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1385929645499 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1385929645500 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1385929645500 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1385929645501 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1385929645501 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1385929645502 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1385929645502 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1385929645503 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1385929645503 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1385929645503 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1385929645503 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1385929645504 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1385929645504 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1385929645504 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1385929645505 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1385929645505 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1385929645505 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1385929645506 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1385929645506 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1385929645506 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1385929645506 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1385929645507 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1385929645507 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1385929645508 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1385929645508 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1385929645509 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1385929645509 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1385929645510 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1385929645510 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1385929645510 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1385929645510 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1385929645511 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1385929645511 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1385929645512 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1385929645512 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1385929645512 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1385929645513 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1385929645513 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1385929645513 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1385929645514 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1385929645514 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1385929645514 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1385929645514 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1385929645515 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1385929645515 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1385929645515 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1385929645516 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1385929645516 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1385929645516 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1385929645517 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1385929645517 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1385929645518 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1385929645518 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1385929645519 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1385929645519 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1385929645520 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1385929645520 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1385929645520 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1385929645520 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1385929645521 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1385929645521 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1385929645521 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1385929645522 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1385929645522 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1385929645523 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1385929645523 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1385929645524 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1385929645525 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1385929645525 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1385929645526 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1385929645526 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1385929645526 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1385929645527 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1385929645528 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1385929645528 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1385929645529 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1385929645529 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1385929645529 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1385929645530 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1385929645531 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1385929645531 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1385929645532 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1385929645532 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1385929645533 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1385929645533 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1385929645533 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1385929645533 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1385929645534 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1385929645534 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1385929645534 -os,sysinfo,,,"linux",1385929645536 -arch,sysinfo,,,"x86",1385929645536 -ws,sysinfo,,,"gtk",1385929645536 -locale,sysinfo,,,"en_US",1385929645536 -processors,sysinfo,,,"8",1385929645536 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1385929645536 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1385929645536 -java.specification.name,sysinfo,,,"Java Platform API Specification",1385929645536 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1385929645536 -java.specification.version,sysinfo,,,"1.6",1385929645536 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1385929645536 -java.version,sysinfo,,,"1.6.0_23",1385929645536 -java.vm.info,sysinfo,,,"mixed mode",1385929645536 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1385929645536 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1385929645536 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1385929645536 -java.vm.specification.version,sysinfo,,,"1.0",1385929645536 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1385929645536 -java.vm.version,sysinfo,,,"19.0-b09",1385929645536 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385929705028 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385929805370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385929816947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929832372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929832537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929832688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929832840 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929832976 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929833128 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929835442 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385929848614 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385929866027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385929886526 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385929893814 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385929896316 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385929902261 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930047614 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930080899 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930083062 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385930136625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930154907 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930167400 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930172172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930177903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930205950 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930209654 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930214448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930219808 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930269594 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385930279187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385930282222 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930293360 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930295269 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385930305205 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385930305237 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385930311620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930330831 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930332659 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930333103 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930377285 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930378639 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload22.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload22.csv deleted file mode 100644 index 1ad51e8..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload22.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930585321 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385930605588 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385930607869 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930608925 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930648087 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930649547 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930653796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385930680568 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1385930680888 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930680898 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930695079 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930706430 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930712406 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930901704 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930910028 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385930945953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385930963863 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385930973850 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385930976469 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931241189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385931251051 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385931253017 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1385931263751 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385931263806 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385931267264 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385931267533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385931274337 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931308821 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931528608 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931540288 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931575839 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385931646103 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385931646323 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385931646859 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385931653988 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385931657203 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385931684113 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385931690057 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1385931692663 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931692825 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931693116 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385931701465 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385931705567 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931746267 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931808393 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931814353 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931815015 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931816845 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385931851859 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932003110 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932115947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385932149541 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932150965 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932151404 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932155343 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932208597 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932209910 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932215440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932221777 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932221919 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932226318 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932235638 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932236010 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932252533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932398745 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932400065 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932404490 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932414884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932459388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932463714 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385932467713 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385932468031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932485129 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932503659 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932504642 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932506790 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932507678 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932509454 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932512461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932515429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932565714 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932567618 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932606722 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932614145 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932624634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932650094 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932650406 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932677242 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932748402 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1385932748667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932748676 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932759934 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932762417 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932764694 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932765148 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932765485 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932767099 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932767210 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932846076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932870897 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932877550 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932883747 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932915251 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385932916158 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932953720 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932964234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385932969738 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385932970636 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385932984208 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385932985931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933026408 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933060759 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933065807 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933079343 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385933083261 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385933083555 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385933106322 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933107219 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933107669 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933114828 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385933119380 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933124449 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933153066 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933158704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933159081 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933160072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933160400 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933184832 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933190297 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933190953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933199177 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933242105 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933246538 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933252974 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933256970 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933259792 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933262842 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933263513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933279698 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933283065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933286729 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933287337 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933289472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933289759 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933297511 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933329454 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933337090 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385933340545 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933348969 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933349480 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933349935 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933350239 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933350423 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933362285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933362760 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933363047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933363246 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933363567 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933365370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933382824 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933401989 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933407032 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933408975 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933409874 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933410228 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933423209 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933425108 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933425663 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933437197 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933485934 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933488860 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933505368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933574774 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933583951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933585821 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933588227 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933597551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933633392 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933638873 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933643771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933655884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933666920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933683350 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933684403 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933736669 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933738981 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933740156 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933749570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933755113 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385933757921 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933760205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933771219 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933777215 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933801074 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933802161 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933832484 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933837165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933837340 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385933837515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933843574 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933846339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385933858713 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385933872110 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385933883647 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385933900001 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385933901911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934045517 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934046115 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934051142 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934063306 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385934083347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934083965 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934084603 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934086335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934087913 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934088264 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934124218 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934125634 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934139515 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934183559 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934185735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934205167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934211655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934215218 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385934218759 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385934218956 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385934219189 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934222529 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934227165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934228194 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934228782 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934237516 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934238379 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934238719 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934247801 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934269290 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934282870 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934288388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934289632 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934289791 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934289935 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934290072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934291625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934293913 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934300158 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934302915 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934303232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934324318 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934329807 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934330147 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385934332643 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1385934332818 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934333277 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934347222 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934353494 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934389030 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934389363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934391521 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385934404382 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934405012 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934405232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934409660 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934409958 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934410631 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934410878 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934411341 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934414821 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934452709 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934458704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934460259 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934472725 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934481933 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934487604 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934487930 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934505984 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload23.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload23.csv deleted file mode 100644 index b8c9989..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload23.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934532757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934537519 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934537646 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934538528 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934550070 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934558198 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934559844 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934560195 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1385934565764 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1385934565774 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1385934565774 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1385934565775 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934565806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934568566 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934573277 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934573647 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934585916 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934588005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934596844 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934599122 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934605839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934607724 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934608000 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934614113 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934617012 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934619163 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934619493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934627700 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934642884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934652529 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934654011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934657828 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385934661453 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934662051 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385934662673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934663069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934665408 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934665720 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934679010 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934680944 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934681174 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934684550 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934688453 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934689919 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934691162 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934691398 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934694605 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934698866 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934700476 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934701997 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934702606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934703156 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934703819 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934711779 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934713839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934715005 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934715186 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934716456 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934725642 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934725663 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934751702 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385934753789 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934755096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934755640 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934756292 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934789533 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385934789556 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934867361 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385934915426 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934939434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934942170 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934966011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385934968329 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385934986948 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385934999279 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935002808 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935013214 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935013480 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935014773 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935016305 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935016837 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935017720 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935110207 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385935110228 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935129756 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935130633 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935134380 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935135252 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935136181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935136618 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935165709 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935170023 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385935187888 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935189968 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935192961 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.close",1385935193799 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935193807 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935194432 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385935217096 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935233776 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935236604 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935237885 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935239426 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935239959 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935241006 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935288412 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385935288436 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935291461 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935293881 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935306271 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935318321 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935319806 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935320344 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385935325310 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385935327175 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935333077 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935339027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385935341166 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935341906 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935343365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935344929 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935345448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935345967 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935347257 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935348562 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935349109 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935349993 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935400299 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385935400324 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1385935408639 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935409366 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935411005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935414552 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935416433 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935416740 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1385935448630 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1385935453636 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935465103 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935472926 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935474341 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935474874 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935475586 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935493769 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1385935493786 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1385935501681 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1385935502289 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1385935503740 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935505039 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935505577 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1385935505952 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386096903369 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386096944163 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1386096974633 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386096976839 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1386096976850 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386096977434 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386096982515 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386096984391 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386097001230 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386097006035 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386097012102 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386097051899 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386097080395 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1386097082553 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386097097827 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386097292759 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386097301280 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386178942929 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386178952100 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386178967689 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181394220 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181427944 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181698664 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181699925 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181711244 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181712578 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181717174 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181718717 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181733178 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181733598 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181736025 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181737842 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181738299 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181739161 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181741423 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181776833 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181791264 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181803321 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181810717 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181822898 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181892839 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386181903999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181906370 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181907072 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181908770 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181960919 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386181963831 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386182080799 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386182084296 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386184390798 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184440483 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184445507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184448911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184451913 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184459018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184465667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184467359 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184468394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184487274 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184499018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184512065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184524151 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184535382 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184537194 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1386184537479 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386184537485 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386184543325 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184546364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548035 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548187 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548887 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184548966 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184549007 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184549179 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184550640 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184551652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184551843 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184552018 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184552178 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184555777 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184609563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184628117 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184645450 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184646381 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184647334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184647887 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184673861 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184674059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184674235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184674402 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184689981 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184697660 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184712544 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1386184718833 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184721396 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184721578 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184722060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184725001 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184726995 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1386184727161 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184727539 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184730591 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184732912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1386184735148 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1386184740351 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1386184750581 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1386184766213 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386184779534 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386192919369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386192969682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386193060195 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386193060257 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386437502475 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1386437502498 -error,log,,,"Unhandled event loop exception",1386437502590 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386437506257 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386549038252 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386549039943 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1386549041510 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1386549041757 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1386549041758 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1386549041760 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1386549041760 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload24.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload24.csv deleted file mode 100644 index ce434e6..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload24.csv +++ /dev/null @@ -1,262 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1386549041761 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1386549041761 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1386549041763 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1386549041764 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1386549041765 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1386549041767 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1386549041769 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1386549041771 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1386549041775 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1386549041777 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1386549041778 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1386549041778 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1386549041786 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1386549041787 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1386549041787 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1386549041794 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1386549041794 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1387837601946 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1387837601947 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1387837601947 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1387837601948 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1387837601948 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1387837601948 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1387837601948 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1387837601948 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1387837601948 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1387837601948 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1387837601948 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1387837601948 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1387837601949 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1387837601949 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1387837601949 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1387837601949 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1387837601949 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1387837601949 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1387837601949 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1387837601949 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1387837601949 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1387837601949 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1387837601949 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1387837601949 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1387837601949 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1387837601949 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1387837601949 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1387837601949 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1387837601950 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1387837601950 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1387837601950 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1387837601950 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1387837601950 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1387837601951 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1387837601951 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1387837601951 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1387837601952 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1387837601952 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1387837601952 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1387837601952 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1387837601952 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1387837601952 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1387837601953 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1387837601953 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1387837601953 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1387837601953 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1387837601953 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1387837601953 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1387837601954 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1387837601954 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1387837601954 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1387837601954 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1387837601954 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1387837601954 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1387837601954 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1387837601954 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1387837601954 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1387837601954 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1387837601954 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1387837601954 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1387837601954 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1387837601954 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1387837601954 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1387837601954 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1387837601954 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1387837601954 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1387837601954 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1387837601954 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1387837601954 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1387837601955 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1387837601955 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1387837601955 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1387837601955 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1387837601955 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1387837601955 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1387837601955 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1387837601955 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1387837601955 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1387837601955 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1387837601955 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1387837601955 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1387837601955 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1387837601955 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1387837601955 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1387837601956 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1387837601956 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1387837601956 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1387837601956 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1387837601956 -os,sysinfo,,,"linux",1387837601958 -arch,sysinfo,,,"x86",1387837601958 -ws,sysinfo,,,"gtk",1387837601958 -locale,sysinfo,,,"en_US",1387837601958 -processors,sysinfo,,,"8",1387837601958 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1387837601958 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1387837601958 -java.specification.name,sysinfo,,,"Java Platform API Specification",1387837601958 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1387837601958 -java.specification.version,sysinfo,,,"1.6",1387837601958 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1387837601958 -java.version,sysinfo,,,"1.6.0_23",1387837601958 -java.vm.info,sysinfo,,,"mixed mode",1387837601958 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1387837601958 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1387837601958 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1387837601958 -java.vm.specification.version,sysinfo,,,"1.0",1387837601958 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1387837601958 -java.vm.version,sysinfo,,,"19.0-b09",1387837601958 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1387837602356 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1387837602556 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1387837603010 -error,log,,,"Unhandled event loop exception",1387837603112 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1387837625853 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837628198 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837638045 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1387837639365 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1387837644183 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1387837644220 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1387837644230 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1387837645143 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1387837654154 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1387837656014 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1387837661160 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1387837663217 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1387837665663 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1387837665997 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837667928 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1387837668279 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1387837668285 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1387837668285 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1387837668286 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837668771 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837674568 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837677306 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837679642 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837680748 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387837686647 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387896873834 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387896878701 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387992251973 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1387992253016 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388016126315 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388016126764 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1388016128492 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388016128566 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1388016128886 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1388016128886 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1388016128886 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1388016128887 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1388016128887 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1388016128887 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1388016128887 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1388016128887 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1388016128889 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1388016128889 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1388016128889 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1388016128889 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1388016128889 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1388016128889 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1388016128889 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1388016128889 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1388016128889 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1388016128889 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1388016128889 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1388016128889 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1388016128890 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1388016128890 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1388016128890 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1388016128890 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1388016128890 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1388016128890 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1388016128890 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1388016128890 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.1.0.162,"com.altera.sbtgui.flash.plugin",1388016128890 -stopped,bundle,com.altera.sbtgui.gprof,13.1.0.162,"com.altera.sbtgui.gprof",1388016128890 -stopped,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1388016128890 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1388016128892 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1388016128893 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1388016128894 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1388016128894 -stopped,bundle,org.eclipse.equinox.p2.ui.sdk,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk",1388016128894 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1388016128895 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1388016128895 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1388016128895 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1388016128895 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1388016128895 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1388016128903 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1388016128904 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1388016128904 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1388016128904 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1388016128904 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1388016128904 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1388016128904 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1388016128904 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1388016128904 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1388016128905 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1388016128905 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1388016128905 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1388016128905 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1388016128905 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1388016128905 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1388016128905 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1388016128906 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1388016128906 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1388016128917 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1388016128917 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1388016128917 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1388016128917 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1388109482853 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1388109482854 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1388109482854 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1388109482855 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1388109482855 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1388109482855 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1388109482855 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1388109482855 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1388109482855 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1388109482855 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1388109482855 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1388109482855 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1388109482856 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1388109482856 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1388109482856 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1388109482856 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1388109482856 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1388109482856 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1388109482856 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1388109482856 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1388109482856 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1388109482857 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1388109482857 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1388109482857 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1388109482857 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload25.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload25.csv deleted file mode 100644 index ed63d27..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload25.csv +++ /dev/null @@ -1,266 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1388109482857 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1388109482857 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1388109482857 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1388109482857 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1388109482857 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1388109482857 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1388109482857 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1388109482858 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1388109482858 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1388109482858 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1388109482858 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1388109482859 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1388109482859 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1388109482859 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1388109482859 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1388109482859 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1388109482859 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1388109482859 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1388109482859 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1388109482860 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1388109482860 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1388109482860 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1388109482860 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1388109482860 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1388109482860 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1388109482860 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1388109482860 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1388109482860 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1388109482860 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1388109482860 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1388109482860 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1388109482861 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1388109482861 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1388109482861 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1388109482861 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1388109482861 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1388109482861 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1388109482861 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1388109482861 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1388109482861 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1388109482861 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1388109482861 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1388109482861 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1388109482861 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1388109482861 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1388109482861 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1388109482861 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1388109482862 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1388109482862 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1388109482862 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1388109482862 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1388109482862 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1388109482862 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1388109482862 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1388109482862 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1388109482862 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1388109482862 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1388109482862 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1388109482862 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1388109482862 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1388109482862 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1388109482862 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1388109482862 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1388109482862 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1388109482863 -os,sysinfo,,,"linux",1388109482865 -arch,sysinfo,,,"x86",1388109482865 -ws,sysinfo,,,"gtk",1388109482865 -locale,sysinfo,,,"en_US",1388109482865 -processors,sysinfo,,,"8",1388109482865 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1388109482865 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1388109482865 -java.specification.name,sysinfo,,,"Java Platform API Specification",1388109482865 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1388109482865 -java.specification.version,sysinfo,,,"1.6",1388109482865 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1388109482865 -java.version,sysinfo,,,"1.6.0_23",1388109482865 -java.vm.info,sysinfo,,,"mixed mode",1388109482865 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1388109482865 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1388109482865 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1388109482865 -java.vm.specification.version,sysinfo,,,"1.0",1388109482865 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1388109482865 -java.vm.version,sysinfo,,,"19.0-b09",1388109482865 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1388109483244 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109486007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109510764 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1388109510879 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1388109511337 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1388109514643 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1388109514647 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1388109514647 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1388109514647 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109514702 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109517375 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109526704 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109532132 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109534631 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109534952 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109536710 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109537602 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109537898 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109538639 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388109540016 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388110587169 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388110587721 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388163304522 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388163305203 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388179999907 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388180000837 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388189379694 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388189380495 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388189391065 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388251983787 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388251987620 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388261165735 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388261166132 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388261167582 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388261168488 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388263695689 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388263696224 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388267507882 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388267508394 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388351660956 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1388351660976 -error,log,,,"Unhandled event loop exception",1388351661218 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388351661392 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388372168604 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388372169413 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430697857 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1388430780042 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430782581 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430782618 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1388430782627 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430783164 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1388430790089 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430790218 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430790254 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1388430790264 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430792827 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1388430799817 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1388430801725 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1388430803409 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430803415 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1388430803684 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430809366 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430830342 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430832008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430834101 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430850415 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430852729 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430854977 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430856791 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430858595 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430860236 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430863473 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388430864530 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388445340277 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388445341683 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1388445342961 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1388445343021 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1388445343289 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1388445343289 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1388445343289 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1388445343290 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1388445343290 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1388445343291 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1388445343291 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1388445343291 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1388445343292 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1388445343292 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1388445343292 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1388445343292 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1388445343292 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1388445343292 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1388445343292 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1388445343292 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1388445343292 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1388445343292 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1388445343292 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1388445343293 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1388445343293 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1388445343293 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1388445343293 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1388445343293 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1388445343293 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1388445343293 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1388445343293 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1388445343293 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1388445343293 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1388445343293 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1388445343293 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1388445343294 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1388445343294 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1388445343294 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.1.0.162,"com.altera.sbtgui.flash.plugin",1388445343294 -stopped,bundle,com.altera.sbtgui.gprof,13.1.0.162,"com.altera.sbtgui.gprof",1388445343294 -stopped,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1388445343294 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1388445343295 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1388445343297 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1388445343297 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1388445343298 -stopped,bundle,org.eclipse.equinox.p2.ui.sdk,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk",1388445343298 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1388445343298 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1388445343298 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1388445343298 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1388445343298 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1388445343298 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1388445343305 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1388445343305 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1388445343305 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1388445343306 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1388445343306 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1388445343307 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1388445343307 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1388445343307 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1388445343307 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1388445343308 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1388445343308 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1388445343308 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1388445343308 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1388445343312 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1388445343312 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1388445343312 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1388445343312 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1388445343314 -stopped,bundle,org.eclipse.rse.subsystems.files.ssh,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.ssh",1388445343314 -stopped,bundle,org.eclipse.rse.subsystems.shells.ssh,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.ssh",1388445343314 -stopped,bundle,org.eclipse.rse.subsystems.terminals.ssh,1.0.100.v201101042155,"org.eclipse.rse.subsystems.terminals.ssh",1388445343314 -stopped,bundle,org.eclipse.rse.connectorservice.ssh,2.1.200.v201101042155,"org.eclipse.rse.connectorservice.ssh",1388445343314 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1389119430038 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1389119430039 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1389119430039 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1389119430039 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1389119430039 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1389119430039 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1389119430039 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1389119430039 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1389119430039 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1389119430039 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1389119430040 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1389119430040 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1389119430040 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1389119430040 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1389119430040 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1389119430040 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1389119430040 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1389119430040 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1389119430040 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1389119430040 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1389119430041 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1389119430041 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1389119430041 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1389119430041 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1389119430041 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload26.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload26.csv deleted file mode 100644 index 00ac1ab..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload26.csv +++ /dev/null @@ -1,261 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1389119430041 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1389119430041 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1389119430041 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1389119430041 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1389119430041 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1389119430041 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1389119430042 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1389119430042 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1389119430042 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1389119430042 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1389119430042 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1389119430043 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1389119430043 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1389119430043 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1389119430043 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1389119430043 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1389119430043 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1389119430043 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1389119430043 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1389119430043 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1389119430043 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1389119430044 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1389119430044 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1389119430044 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1389119430044 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1389119430044 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1389119430044 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1389119430044 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1389119430044 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1389119430044 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1389119430044 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1389119430045 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1389119430045 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1389119430045 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1389119430045 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1389119430045 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1389119430045 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1389119430045 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1389119430045 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1389119430045 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1389119430045 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1389119430045 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1389119430045 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1389119430045 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1389119430045 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1389119430045 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1389119430045 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1389119430046 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1389119430046 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1389119430046 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1389119430046 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1389119430046 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1389119430046 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1389119430046 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1389119430046 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1389119430046 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1389119430046 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1389119430046 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1389119430046 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1389119430046 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389119430046 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389119430046 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1389119430046 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1389119430046 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1389119430047 -os,sysinfo,,,"linux",1389119430049 -arch,sysinfo,,,"x86",1389119430049 -ws,sysinfo,,,"gtk",1389119430049 -locale,sysinfo,,,"en_US",1389119430049 -processors,sysinfo,,,"8",1389119430049 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1389119430049 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1389119430049 -java.specification.name,sysinfo,,,"Java Platform API Specification",1389119430049 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389119430049 -java.specification.version,sysinfo,,,"1.6",1389119430049 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1389119430049 -java.version,sysinfo,,,"1.6.0_23",1389119430049 -java.vm.info,sysinfo,,,"mixed mode",1389119430049 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1389119430049 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1389119430049 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389119430049 -java.vm.specification.version,sysinfo,,,"1.0",1389119430049 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1389119430049 -java.vm.version,sysinfo,,,"19.0-b09",1389119430049 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1389119430265 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1389119431103 -error,log,,,"Unhandled event loop exception",1389119431187 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389119477726 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1389119478162 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1389119481579 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1389119481583 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1389119481583 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389119481583 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119481628 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119484427 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119486078 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119486438 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119488841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119489039 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119492597 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119492984 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119494820 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119496072 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119496113 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119496890 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119498364 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119498987 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119500605 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119525944 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119526553 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119571054 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389119577182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389119579334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389119579779 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119579787 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119583480 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119602991 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119655375 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119656526 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119667535 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119679799 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119681008 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389119686357 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389121474393 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389121474433 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1389121475813 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389121475886 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1389121476249 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1389121476249 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1389121476249 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389121476250 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1389121476250 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389121476250 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1389121476250 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1389121476251 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1389121476252 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1389121476252 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1389121476252 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1389121476252 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1389121476252 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1389121476252 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1389121476253 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.dsf.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.gdb.ui,7.0.0.201202111925,"org.eclipse.cdt.gdb.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1389121476253 -stopped,bundle,org.eclipse.cdt.launch,7.0.0.201202111925,"org.eclipse.cdt.launch",1389121476253 -stopped,bundle,org.eclipse.cdt.debug.ui,7.1.2.201202111925,"org.eclipse.cdt.debug.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.traditional,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.traditional",1389121476253 -stopped,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1389121476253 -stopped,bundle,org.eclipse.cdt.debug.core,7.1.0.201202111925,"org.eclipse.cdt.debug.core",1389121476253 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.ui,1.0.1.201202152032,"org.eclipse.linuxtools.cdt.autotools.ui",1389121476253 -stopped,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1389121476253 -stopped,bundle,org.eclipse.cdt.managedbuilder.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.managedbuilder.gnu.ui,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.gnu.ui",1389121476253 -stopped,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1389121476253 -stopped,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1389121476254 -stopped,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1389121476254 -stopped,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1389121476255 -stopped,bundle,org.eclipse.cdt.codan.ui,2.0.1.201202111925,"org.eclipse.cdt.codan.ui",1389121476255 -stopped,bundle,com.altera.sbtgui.flash.plugin,13.1.0.162,"com.altera.sbtgui.flash.plugin",1389121476255 -stopped,bundle,com.altera.sbtgui.gprof,13.1.0.162,"com.altera.sbtgui.gprof",1389121476255 -stopped,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1389121476255 -stopped,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1389121476258 -stopped,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1389121476259 -stopped,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1389121476259 -stopped,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1389121476259 -stopped,bundle,org.eclipse.equinox.p2.ui.sdk,1.0.200.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk",1389121476260 -stopped,bundle,org.eclipse.rse.importexport,1.2.200.v201105021534,"org.eclipse.rse.importexport",1389121476260 -stopped,bundle,org.eclipse.rse.subsystems.shells.telnet,1.2.200.v201101042155,"org.eclipse.rse.subsystems.shells.telnet",1389121476260 -stopped,bundle,org.eclipse.rse.shells.ui,3.0.301.R33x_v201107181530,"org.eclipse.rse.shells.ui",1389121476260 -stopped,bundle,org.eclipse.rse.files.ui,3.2.1.R33x_v201109141647,"org.eclipse.rse.files.ui",1389121476260 -stopped,bundle,org.eclipse.rse.processes.ui,3.0.300.v201101042155,"org.eclipse.rse.processes.ui",1389121476260 -stopped,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1389121476267 -stopped,bundle,org.eclipse.mylyn.commons.team,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.team",1389121476267 -stopped,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1389121476268 -stopped,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1389121476268 -stopped,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1389121476268 -stopped,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.ide.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.ide.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.resources.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.resources.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.wikitext.tasks.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.tasks.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.help.ui,3.6.1.v20110830-0100,"org.eclipse.mylyn.help.ui",1389121476268 -stopped,bundle,org.eclipse.mylyn.tasks.bugs,3.6.1.v20110825-0100,"org.eclipse.mylyn.tasks.bugs",1389121476269 -stopped,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1389121476269 -stopped,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1389121476269 -stopped,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1389121476269 -stopped,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1389121476269 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.transport,2.1.0.201202111925,"org.eclipse.cdt.debug.ui.memory.transport",1389121476269 -stopped,bundle,org.eclipse.ui.externaltools,3.2.0.v20111007_r372,"org.eclipse.ui.externaltools",1389121476269 -stopped,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1389121476274 -stopped,bundle,org.eclipse.mylyn.wikitext.ui,1.5.0.v20110608-1400,"org.eclipse.mylyn.wikitext.ui",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.files.dstore,2.1.201.R33x_v201109141647,"org.eclipse.rse.subsystems.files.dstore",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.processes.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.dstore",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.shells.dstore,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.dstore",1389121476274 -stopped,bundle,org.eclipse.rse.connectorservice.dstore,3.1.200.v201103141607,"org.eclipse.rse.connectorservice.dstore",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.files.local,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.local",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.processes.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.processes.local",1389121476274 -stopped,bundle,org.eclipse.rse.subsystems.shells.local,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.local",1389121476274 -stopped,bundle,org.eclipse.rse.connectorservice.local,2.1.300.v201101042155,"org.eclipse.rse.connectorservice.local",1389121476275 -stopped,bundle,org.eclipse.rse.subsystems.files.ssh,2.1.200.v201101042155,"org.eclipse.rse.subsystems.files.ssh",1389121476275 -stopped,bundle,org.eclipse.rse.subsystems.shells.ssh,2.1.300.v201101042155,"org.eclipse.rse.subsystems.shells.ssh",1389121476275 -stopped,bundle,org.eclipse.rse.subsystems.terminals.ssh,1.0.100.v201101042155,"org.eclipse.rse.subsystems.terminals.ssh",1389121476275 -stopped,bundle,org.eclipse.rse.connectorservice.ssh,2.1.200.v201101042155,"org.eclipse.rse.connectorservice.ssh",1389121476275 -stopped,bundle,org.eclipse.rse.connectorservice.telnet,1.2.200.v201101042155,"org.eclipse.rse.connectorservice.telnet",1389121476276 -stopped,bundle,org.eclipse.rse.dstore.security,3.0.300.v201103141607,"org.eclipse.rse.dstore.security",1389121476276 -stopped,bundle,org.eclipse.rse.efs,2.1.300.v201101042155,"org.eclipse.rse.efs",1389121476276 -stopped,bundle,org.eclipse.rse.subsystems.files.ftp,2.1.301.R33x_v201107212114,"org.eclipse.rse.subsystems.files.ftp",1389121476276 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1389294893056 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1389294893057 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1389294893057 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1389294893058 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1389294893058 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1389294893059 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1389294893059 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1389294893060 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1389294893060 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1389294893060 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1389294893061 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1389294893061 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1389294893062 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1389294893062 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1389294893062 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1389294893063 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1389294893063 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1389294893064 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1389294893064 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1389294893064 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1389294893065 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1389294893065 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1389294893066 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1389294893066 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1389294893067 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1389294893224 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1389294893225 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1389294893225 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1389294893225 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1389294893226 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1389294893226 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1389294893226 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1389294893227 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1389294893227 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1389294893228 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1389294893228 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1389294893229 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1389294893229 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1389294893229 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1389294893229 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1389294893230 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1389294893230 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1389294893230 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1389294893230 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1389294893231 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1389294893231 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1389294893231 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1389294893232 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1389294893232 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1389294893232 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload27.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload27.csv deleted file mode 100644 index 711db69..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload27.csv +++ /dev/null @@ -1,288 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1389294893233 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1389294893233 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1389294893234 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1389294893234 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1389294893235 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1389294893235 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1389294893235 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1389294893235 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1389294893236 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1389294893236 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1389294893237 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1389294893237 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1389294893237 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1389294893238 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1389294893238 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1389294893239 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1389294893239 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1389294893240 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1389294893240 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1389294893241 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1389294893241 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1389294893241 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1389294893242 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1389294893243 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1389294893243 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1389294893243 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1389294893244 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1389294893244 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1389294893245 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1389294893245 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1389294893245 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1389294893246 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1389294893247 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1389294893247 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1389294893247 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389294893247 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389294893248 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1389294893248 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1389294893248 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1389294893248 -os,sysinfo,,,"linux",1389294893250 -arch,sysinfo,,,"x86",1389294893250 -ws,sysinfo,,,"gtk",1389294893250 -locale,sysinfo,,,"en_US",1389294893250 -processors,sysinfo,,,"8",1389294893250 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1389294893250 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1389294893250 -java.specification.name,sysinfo,,,"Java Platform API Specification",1389294893250 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389294893251 -java.specification.version,sysinfo,,,"1.6",1389294893251 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1389294893251 -java.version,sysinfo,,,"1.6.0_23",1389294893251 -java.vm.info,sysinfo,,,"mixed mode",1389294893251 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1389294893251 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1389294893251 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389294893251 -java.vm.specification.version,sysinfo,,,"1.0",1389294893251 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1389294893251 -java.vm.version,sysinfo,,,"19.0-b09",1389294893251 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389294925508 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389294927422 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389294927632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389294983528 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389294989609 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389295001091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389295002782 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389295006535 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389295006639 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389295006680 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389295006689 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389295007167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389295008177 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389295008184 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389295008355 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389295011750 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389295024722 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389295068355 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296402020 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389296434337 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389296434591 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296434599 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296440673 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296445314 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296445821 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296446203 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296446951 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296450853 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296575380 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389296577727 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389299702281 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389299703646 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389299836988 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389299837577 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301304765 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301305233 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301306584 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301307191 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301700340 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301707185 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301723099 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301723761 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301724839 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389301728843 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301728852 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301733829 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389301761680 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1389301762117 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301763848 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301764349 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1389301768171 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1389301768185 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1389301768186 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389301768187 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301768232 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301771270 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301773709 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301773883 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301776784 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301776962 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301780229 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301780627 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301782515 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301783440 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301783737 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301784464 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389301788501 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389301789983 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389301791464 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301793007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301793742 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389301796849 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389301798954 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389301800151 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301801545 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301802608 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389301803151 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301803311 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301804038 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389301805714 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389301807078 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301808267 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301808891 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389301828698 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389301841203 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389301845192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389301845581 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389301853373 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301854750 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301855344 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301858197 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301884452 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301888467 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301889927 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389301894786 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302254697 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389302288323 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389302291046 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389302294125 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302295597 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302296477 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302300538 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302308111 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302311470 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302311637 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302312345 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302447764 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389302449192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389302450244 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389302450386 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389302450879 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302487513 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302488208 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302488612 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302530989 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389302533101 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302534818 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302535615 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302536884 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302554735 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302566993 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302962516 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389302974927 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389302987660 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389302989163 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302990308 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302991260 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389302992139 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389303007963 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389303010905 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389303011078 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389303012404 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304445839 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389304450768 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304458729 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304458980 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389304460339 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304469214 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304469363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304469796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389304469931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389304470302 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389304472034 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304473383 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304474368 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304502659 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304540238 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304575389 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304575564 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304576549 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304633509 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304636198 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304636308 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389304637131 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389396927260 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389396929696 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389481896445 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389481897292 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389487518804 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389487520122 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1389487521659 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389487521736 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1389487522024 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1389487522025 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1389487522027 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389487522027 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1389487522028 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389487522028 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1389487522030 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1389487522031 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1389487522032 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1389487522036 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1389487522038 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1389487522039 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1389487522043 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1389487522044 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1389487522046 -stopped,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389487522046 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1389814193014 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1389814193015 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1389814193016 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1389814193016 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1389814193016 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1389814193017 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1389814193017 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1389814193018 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1389814193018 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1389814193018 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1389814193019 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1389814193019 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1389814193019 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1389814193020 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1389814193020 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1389814193020 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1389814193020 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1389814193021 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1389814193021 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1389814193021 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1389814193022 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1389814193022 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1389814193022 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1389814193023 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1389814193023 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1389814193024 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1389814193025 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1389814193025 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1389814193025 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1389814193025 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1389814193026 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1389814193026 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1389814193027 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1389814193027 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1389814193027 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1389814193028 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1389814193028 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1389814193028 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1389814193029 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1389814193029 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1389814193029 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1389814193030 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1389814193031 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1389814193031 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1389814193031 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1389814193032 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1389814193033 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1389814193033 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1389814193033 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1389814193034 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload28.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload28.csv deleted file mode 100644 index c5c1a35..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload28.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1389814193035 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1389814193035 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1389814193035 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1389814193036 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1389814193036 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1389814193037 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1389814193037 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1389814193037 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1389814193037 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1389814193038 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1389814193038 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1389814193039 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1389814193039 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1389814193040 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1389814193040 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1389814193041 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1389814193041 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1389814193042 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1389814193042 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1389814193193 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1389814193193 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1389814193193 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1389814193194 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1389814193195 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1389814193196 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1389814193196 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1389814193196 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1389814193196 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1389814193197 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1389814193198 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1389814193198 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1389814193199 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1389814193199 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1389814193200 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1389814193200 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389814193200 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389814193200 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1389814193201 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1389814193201 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1389814193201 -os,sysinfo,,,"linux",1389814193203 -arch,sysinfo,,,"x86",1389814193203 -ws,sysinfo,,,"gtk",1389814193203 -locale,sysinfo,,,"en_US",1389814193203 -processors,sysinfo,,,"8",1389814193203 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1389814193204 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1389814193204 -java.specification.name,sysinfo,,,"Java Platform API Specification",1389814193204 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389814193204 -java.specification.version,sysinfo,,,"1.6",1389814193204 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1389814193204 -java.version,sysinfo,,,"1.6.0_23",1389814193204 -java.vm.info,sysinfo,,,"mixed mode",1389814193204 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1389814193204 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1389814193204 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389814193204 -java.vm.specification.version,sysinfo,,,"1.0",1389814193204 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1389814193204 -java.vm.version,sysinfo,,,"19.0-b09",1389814193204 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1389814193311 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1389814194222 -error,log,,,"Unhandled event loop exception",1389814194301 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814195320 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389814198269 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389814199922 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814229777 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814231278 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814231372 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814236057 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814240874 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814297751 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389814299000 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389814299035 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389814305756 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389814328606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389814342871 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818086994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389818107381 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389818109338 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389818112934 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389818115759 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389818118440 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389818121421 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1389818122203 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389818123777 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389818124275 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389818129190 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1389818129576 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818130982 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1389818131330 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1389818131340 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1389818131341 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389818131342 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818131835 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818135030 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818137715 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818139393 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818139487 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389818141502 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389825627581 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389825629350 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389825653253 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389825653945 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389904978944 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389904982276 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389904983349 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389904987306 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389904989297 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389904992608 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389904993065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389904995618 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389904995814 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389904996384 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389904998213 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905000156 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905000754 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389905002239 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905005674 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905006189 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905006962 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905013489 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389905014828 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389912295638 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389912296456 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913050233 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913051863 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913957758 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389913958908 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913961289 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913963936 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913971618 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913971928 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913973605 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389913979369 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389913985874 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913991779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913991953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913992104 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913992256 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913992400 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913992536 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1389913992696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389913995563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389913998623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1389914003092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1389914006671 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389914010113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914010123 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914018861 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1389914019849 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389914021719 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914023123 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914023792 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389914034448 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389914034458 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389914034832 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1389914035801 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914035808 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914043060 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914058665 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914626919 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389914628455 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914630521 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914633213 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914637180 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914637445 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914638081 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914638351 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914639404 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914645314 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914645372 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389914646103 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389914649655 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389914649677 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1389914649678 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1389998377033 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1389998377034 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1389998377034 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1389998377035 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1389998377035 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1389998377035 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1389998377036 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1389998377036 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1389998377036 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1389998377036 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1389998377037 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1389998377037 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1389998377038 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1389998377038 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1389998377038 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1389998377039 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1389998377039 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1389998377039 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1389998377040 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1389998377040 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1389998377040 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1389998377040 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1389998377041 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1389998377041 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1389998377042 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1389998377042 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1389998377043 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1389998377043 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1389998377043 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1389998377044 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1389998377044 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1389998377044 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1389998377044 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1389998377045 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1389998377045 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1389998377046 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1389998377046 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1389998377046 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1389998377047 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1389998377047 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1389998377048 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1389998377048 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1389998377048 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1389998377049 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1389998377049 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1389998377049 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1389998377050 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1389998377050 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1389998377050 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1389998377051 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1389998377051 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1389998377052 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1389998377052 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1389998377053 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1389998377053 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1389998377053 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1389998377054 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1389998377054 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1389998377054 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1389998377054 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1389998377055 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1389998377055 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1389998377056 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1389998377056 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1389998377057 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1389998377057 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1389998377057 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1389998377058 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1389998377059 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1389998377060 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1389998377060 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1389998377060 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1389998377060 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1389998377061 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1389998377062 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1389998377062 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1389998377062 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1389998377062 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1389998377063 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1389998377064 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1389998377064 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1389998377064 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1389998377065 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1389998377065 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1389998377065 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1389998377066 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1389998377066 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1389998377066 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1389998377066 -os,sysinfo,,,"linux",1389998377068 -arch,sysinfo,,,"x86",1389998377068 -ws,sysinfo,,,"gtk",1389998377068 -locale,sysinfo,,,"en_US",1389998377068 -processors,sysinfo,,,"8",1389998377068 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1389998377068 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1389998377069 -java.specification.name,sysinfo,,,"Java Platform API Specification",1389998377069 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389998377069 -java.specification.version,sysinfo,,,"1.6",1389998377069 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1389998377069 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload29.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload29.csv deleted file mode 100644 index 618f305..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload29.csv +++ /dev/null @@ -1,265 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -java.version,sysinfo,,,"1.6.0_23",1389998377069 -java.vm.info,sysinfo,,,"mixed mode",1389998377069 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1389998377069 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1389998377069 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1389998377069 -java.vm.specification.version,sysinfo,,,"1.0",1389998377069 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1389998377069 -java.vm.version,sysinfo,,,"19.0-b09",1389998377069 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1389998377211 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1389998377235 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1389998380975 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1389998381361 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1389998383610 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1389998383616 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1389998383617 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1389998383618 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998383674 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998386386 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998390020 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998390725 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998391361 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998391394 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998393183 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998398803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998401029 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998401943 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998402250 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998402980 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998408300 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998411606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998412638 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998414653 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998415157 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998416163 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1389998418617 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390063306574 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390063307526 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390066382550 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390066383585 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390077039403 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390077040064 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087804728 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087808927 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087810363 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087811871 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087812853 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390087813515 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390136012101 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390136012562 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390136013746 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390136015379 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390138102250 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139197561 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139244527 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139245009 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139264532 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139273654 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139286926 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390139293682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151734090 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1390151736637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1390151747850 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151749298 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151874763 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1390151880533 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151881789 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151970050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1390151977316 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390151978929 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390165893025 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1390165922494 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390165924472 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390165977719 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390166059450 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1390166113126 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1391027168889 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1391027168890 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1391027168890 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1391027168891 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1391027168891 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1391027168892 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1391027168892 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1391027168893 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1391027168893 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1391027168893 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1391027168894 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1391027168894 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1391027168895 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1391027168895 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1391027168895 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1391027168896 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1391027168896 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1391027168896 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1391027168897 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1391027168897 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1391027168898 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1391027168899 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1391027168899 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1391027168900 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1391027168900 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1391027168901 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1391027168902 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1391027168902 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1391027168902 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1391027168903 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1391027168903 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1391027168903 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1391027168904 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1391027168904 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1391027168905 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1391027168905 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1391027168906 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1391027168906 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1391027168906 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1391027168907 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1391027168907 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1391027168907 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1391027168907 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1391027168908 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1391027168908 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1391027168908 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1391027168909 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1391027168909 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1391027168909 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1391027168910 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1391027168910 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1391027168911 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1391027168911 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1391027168912 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1391027168912 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1391027168913 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1391027168913 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1391027168913 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1391027168913 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1391027168914 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1391027168914 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1391027168914 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1391027168915 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1391027168915 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1391027168916 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1391027168916 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1391027168917 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1391027168918 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1391027168918 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1391027168919 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1391027168919 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1391027168919 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1391027168920 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1391027168921 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1391027168921 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1391027168922 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1391027168922 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1391027168922 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1391027168924 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1391027168924 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1391027168924 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1391027168925 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1391027168926 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1391027168926 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1391027168926 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1391027168927 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1391027168927 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1391027168927 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1391027168927 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1391027168928 -os,sysinfo,,,"linux",1391027168930 -arch,sysinfo,,,"x86",1391027168930 -ws,sysinfo,,,"gtk",1391027168930 -locale,sysinfo,,,"en_US",1391027168930 -processors,sysinfo,,,"8",1391027168930 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1391027168930 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1391027168930 -java.specification.name,sysinfo,,,"Java Platform API Specification",1391027168930 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1391027168930 -java.specification.version,sysinfo,,,"1.6",1391027168930 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1391027168930 -java.version,sysinfo,,,"1.6.0_23",1391027168930 -java.vm.info,sysinfo,,,"mixed mode",1391027168930 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1391027168930 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1391027168930 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1391027168930 -java.vm.specification.version,sysinfo,,,"1.0",1391027168930 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1391027168930 -java.vm.version,sysinfo,,,"19.0-b09",1391027168930 -opened,view,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.views.ProblemView",1391027168978 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1391027169986 -error,log,,,"Unhandled event loop exception",1391027170075 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391027198075 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391030883573 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391030884316 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391031020974 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391031021446 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391035649791 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391035651153 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391036345244 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391036347266 -started,bundle,org.eclipse.cdt.mylyn.ui,3.6.0.v20110608-1400,"org.eclipse.cdt.mylyn.ui",1391036348918 -closed,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1391036348953 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1391036349139 -stopped,bundle,org.eclipse.cdt.build.crossgcc,1.0.2.201202111925,"org.eclipse.cdt.build.crossgcc",1391036349265 -stopped,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1391036349266 -stopped,bundle,com.altera.debug.cdi.gdb.plugin,13.1.0.162,"com.altera.debug.cdi.gdb.plugin",1391036349266 -stopped,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1391036349271 -stopped,bundle,com.altera.sbtgui.ui,13.1.0.162,"com.altera.sbtgui.ui",1391036349271 -stopped,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1391036349271 -stopped,bundle,org.eclipse.cdt.codan.checkers,1.0.1.201202111925,"org.eclipse.cdt.codan.checkers",1391036349273 -stopped,bundle,org.eclipse.cdt.codan.ui.cxx,2.0.0.201202111925,"org.eclipse.cdt.codan.ui.cxx",1391036349273 -stopped,bundle,org.eclipse.cdt.codan.core.cxx,1.0.0.201202111925,"org.eclipse.cdt.codan.core.cxx",1391036349274 -stopped,bundle,org.eclipse.cdt.launch.remote,2.3.0.201202111925,"org.eclipse.cdt.launch.remote",1391036349276 -stopped,bundle,org.eclipse.cdt.debug.mi.ui,6.1.1.201202111925,"org.eclipse.cdt.debug.mi.ui",1391036349277 -stopped,bundle,com.altera.sbt4e.launch,13.1.0.162,"com.altera.sbt4e.launch",1391036349278 -stopped,bundle,org.eclipse.cdt.debug.mi.core,7.1.1.201202111925,"org.eclipse.cdt.debug.mi.core",1391036349282 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.memorybrowser,1.2.100.201202111925,"org.eclipse.cdt.debug.ui.memory.memorybrowser",1391036349283 -stopped,bundle,org.eclipse.cdt.debug.ui.memory.search,1.2.1.201202111925,"org.eclipse.cdt.debug.ui.memory.search",1391036349284 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1395610321057 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1395610321058 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1395610321058 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1395610321058 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1395610321058 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1395610321058 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1395610321058 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1395610321058 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1395610321058 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1395610321058 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1395610321059 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1395610321059 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1395610321059 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1395610321059 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1395610321059 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1395610321059 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1395610321059 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1395610321059 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1395610321059 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1395610321059 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1395610321060 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1395610321060 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1395610321060 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1395610321060 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1395610321060 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1395610321060 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1395610321060 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1395610321060 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1395610321060 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1395610321060 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1395610321060 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1395610321061 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1395610321061 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1395610321061 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1395610321061 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1395610321061 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1395610321062 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1395610321062 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1395610321062 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1395610321062 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1395610321063 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1395610321063 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1395610321063 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1395610321063 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1395610321063 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1395610321063 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1395610321063 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1395610321063 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1395610321064 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1395610321064 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv deleted file mode 100644 index 464b70d..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload3.csv +++ /dev/null @@ -1,301 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438516371 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383438580442 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470702967 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470704496 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470843862 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470847954 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470879971 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470884404 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470893292 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470894212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470894652 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470899028 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383470999412 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471004075 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471004235 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471007212 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471007363 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471026746 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471035046 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471035195 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471038772 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471038931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471047828 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471048011 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471048931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471052509 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471052675 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471057979 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471060965 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471076447 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471081356 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471109794 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471111274 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471134529 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471136524 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471175457 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471177039 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471184002 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471186608 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471289125 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471296728 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471299676 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471300405 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471303735 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471362315 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471368982 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471425058 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471429912 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471435304 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471436286 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471445510 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471447863 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471449232 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471455045 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471456846 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471459976 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471465860 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471473838 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471475954 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471482728 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471482912 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471483072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471483240 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383471483432 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471491667 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471493678 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471497959 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471500325 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471507968 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471510271 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471514740 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471515877 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471518027 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471536651 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471551271 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471557759 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471564384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1383471565644 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471565652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383471577597 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471584629 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471586071 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471586687 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471704537 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471705888 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471821224 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471824112 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471849598 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383471853488 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383472397240 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383472402492 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383472596471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383472607945 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383472650285 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383472656149 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383472712840 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478202634 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478837647 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478841972 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478842613 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478843334 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478844069 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478845699 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478866696 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383478893222 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383478902340 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383478906606 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383478907875 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478911162 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478923245 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383478924122 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479012809 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479013907 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479179341 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479184325 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479307901 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479309554 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479788360 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479793361 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479795079 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383479796585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383479800148 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383479839817 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480071631 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480078445 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480380688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383480382757 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480384467 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480385115 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480385609 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480426681 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383480428019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383480428688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383480432913 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480435518 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480441499 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383480443200 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383480446165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383480446843 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480448869 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480567515 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383480573536 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480576244 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480648921 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480649788 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480722012 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480725701 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480781953 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383480826325 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481045796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481056688 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481056991 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481067470 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481174088 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481179135 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481179310 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383481180571 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481195756 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481358367 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481362632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481415609 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481420246 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481420420 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383481425161 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481427837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481428117 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481435554 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481436400 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481439191 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481456320 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481459323 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481526091 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481529884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481530164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481530372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481530620 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481530868 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481531164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481531396 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481531628 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481531852 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481532060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481536830 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383481538820 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481542334 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481588493 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481592313 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481592815 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481593245 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481598519 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481601649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481605517 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481607564 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481611728 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481613540 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481622743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481625196 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481629727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481631588 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481638223 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481640316 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481645623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481648636 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481652454 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481654236 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383481659060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383481660932 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481663903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481666999 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383481667580 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383481668088 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481701983 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481707531 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383481723924 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482598041 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482599087 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482600963 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482620594 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482649353 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482650912 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482662325 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482677321 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482684841 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482686563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383482696050 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482699045 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482699228 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482699396 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482699579 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383482700087 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482702673 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482705837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482706012 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482706164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482706324 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482706492 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383482706975 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482713420 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482713840 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482724153 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482726577 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482730429 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482730611 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482730771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482730931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383482731092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383482733880 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482743386 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482747876 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383482757420 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483199019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483201666 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483202555 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483204353 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483205312 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483205472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483206317 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483213690 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483218987 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483222797 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483234123 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483236499 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483239961 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483243877 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483266137 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483295541 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483300791 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483309148 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483315841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483416364 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483422093 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483466366 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483467444 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483469328 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483470681 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483610382 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483614263 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483614461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483625774 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483626230 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483632842 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483635823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383483642668 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483644822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483645005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483645181 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483645357 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383483645641 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383483649996 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483652085 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483652301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483653117 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483653549 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383483653872 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483658978 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483681298 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483684169 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483722986 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483743666 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483747863 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv deleted file mode 100644 index 3689fb5..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload4.csv +++ /dev/null @@ -1,301 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483815003 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483821541 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483821716 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483821892 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383483822156 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483824497 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483833209 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483848977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383483858009 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483866757 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483876407 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483878259 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483886199 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383483889047 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484025107 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484036681 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383484038673 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484043579 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484044106 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484046618 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484092173 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484093610 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484150012 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484155083 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484155250 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484155401 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484155554 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484155722 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484168241 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484176222 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484177740 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484180236 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484285049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484301534 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484303311 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484305618 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484312429 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484317387 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484324580 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484346195 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484367289 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484406918 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484409982 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484412145 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484445065 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484462236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484482913 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484522205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484524116 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484531857 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484532263 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484533280 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484534016 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484535743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484541520 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484542140 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484543522 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484559325 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484564392 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484564727 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484568643 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484588262 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484617139 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484617828 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484781479 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484784063 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484784350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484785176 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484863276 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484865130 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484870667 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484872662 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484887391 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484887998 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484888469 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484895805 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484896666 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484914278 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484916889 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484925846 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484926141 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484927389 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383484930618 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484932470 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383484932701 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484938444 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484977251 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484979355 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484979672 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484980309 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484984983 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383484987140 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485018468 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485019417 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485019794 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485020746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485030288 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485033211 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485377802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485389059 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485390524 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485390840 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485393806 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485394716 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485395341 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383485398819 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486248594 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486275287 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486277060 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486281415 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486283252 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486290715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486292052 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486295155 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486299317 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486315441 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486319356 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486322098 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486326967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486336523 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486352117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486356049 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486358854 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486360113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486361410 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486363370 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486378003 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486379033 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486382697 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486385628 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486387089 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486389967 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486404719 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486463416 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486465323 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383486466147 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486467403 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486470243 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486504598 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486515703 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486518331 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486519579 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486520449 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486521738 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486524952 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486529543 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486534410 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486537966 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486556849 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486560854 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486574652 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486576103 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486586601 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486590629 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486626350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486637489 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486727930 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486737392 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486738714 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486754661 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486756108 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486761348 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486767322 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486778286 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486782113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486791461 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486792605 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486805581 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486807953 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383486809819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486817804 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383486825632 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486826822 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486827076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486831437 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486832133 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383486836182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486863702 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486890726 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486894336 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486902517 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486910472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486914837 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486920526 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486924224 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486928213 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486930504 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486936566 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486939309 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486967307 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383486971757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383486975988 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486976444 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383486977528 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383486979996 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487010015 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487012656 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487018519 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487019376 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487091451 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487091882 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487093743 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487099533 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487111889 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487114204 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487116471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487119164 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487121582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487124444 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487126526 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487129308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487131214 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487134488 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487137770 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487142906 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487144085 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487145123 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487148527 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487148693 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487149774 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487149925 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487150618 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487160509 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487182612 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487183375 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487184700 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487185639 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487191880 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487194843 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487231531 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487232795 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487235822 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487240834 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487246607 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487249027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487252222 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487259731 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487261942 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487264566 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487267533 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487270707 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487272806 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487276571 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487278542 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487281419 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487286186 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487289587 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487291501 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487299587 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487301341 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487309267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487311165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383487311779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487312389 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487315786 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487317818 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487333326 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487337493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487343748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487349076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487353644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487363260 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487368148 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487370185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487397028 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487397292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487397539 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487397739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487398563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487399308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487399604 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487399763 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487399907 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487400059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487400211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487400364 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487400516 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487400675 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401375 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401416 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401456 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401497 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401627 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401803 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487401979 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487403708 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404367 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404408 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404448 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404489 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404528 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404568 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404609 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404690 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404729 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487404875 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487405059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487405227 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv deleted file mode 100644 index 8c4af0f..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload5.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487405403 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487405692 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406351 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406392 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406431 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406511 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406551 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406591 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406632 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406672 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406712 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406793 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487406833 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487407075 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487407452 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408111 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408151 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408191 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408231 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408311 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408350 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408391 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408432 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408472 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408553 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408594 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487408755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409131 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409791 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409832 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409872 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487409991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410071 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410111 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410151 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410192 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410232 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410312 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487410755 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411415 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411455 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411496 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411535 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411576 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411617 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411658 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411698 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411738 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411778 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487411819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487412019 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487412203 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487412371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487412820 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487413480 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487413520 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487413715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487413899 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487414051 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487414211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487414379 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487414563 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487414739 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487415003 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487415267 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487415516 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487418124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487418291 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487418951 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487418992 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419032 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419111 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419259 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419435 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487419979 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487420172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487420508 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487423258 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487427874 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487429319 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383487432449 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383487432640 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383487432968 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487436751 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487439815 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487440715 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487443759 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487444525 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487448137 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487449670 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487451993 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487454917 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487457168 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487460113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487463085 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487468734 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487471393 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487473640 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487477366 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487481173 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487483506 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487484691 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487485872 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383487493789 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383487494394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383487494794 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.undo",1383487495125 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487507904 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487509396 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487513172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487515401 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487517645 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383487521122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383487523844 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487527312 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487528858 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487538534 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487545136 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487551178 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487553980 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383487567272 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487568892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487571119 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487600368 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487623338 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383487626221 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383488364762 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488369617 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488370266 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488387393 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488402922 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488407243 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488408167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411149 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411453 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411580 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411717 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488411853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488412005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488417482 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488434299 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488437743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488438855 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488439423 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488439752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488440031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488440263 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488440488 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488440664 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488440847 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488441480 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488441687 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488442112 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488442962 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488460459 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488461918 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488462525 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488463141 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488463701 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488464221 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488464717 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488465229 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488465725 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488466406 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488467165 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488467788 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488467932 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488468974 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488469605 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488469764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488471190 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488471620 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488471780 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488474678 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488474828 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488475943 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488476185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488524273 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488541402 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488549570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488554575 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488555249 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488609680 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383488612417 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383488615190 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488637890 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488640148 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488645977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488714313 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488718020 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488722728 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488742753 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488743995 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488754879 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383488759001 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488759771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488760931 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488761611 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383488762435 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488762998 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488767092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488767314 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488767530 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488768994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488769179 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488769370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488785039 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383488825166 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383488826031 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500269434 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500657564 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500658369 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500867953 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383500883136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383500885127 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383500888527 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383500888763 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383500889032 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500896068 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500902496 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500905639 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500920319 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500942048 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500954170 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500960235 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500965604 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383500966353 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500967314 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500969687 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383500973686 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500976801 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383500980757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383500984087 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383500986730 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383501002814 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383501004005 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383501006653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383501012342 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383502890178 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383502892507 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383502897072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383502899068 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383502899649 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383502936870 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383502937347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383502940195 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383502940355 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383502941480 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383502948648 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383502992505 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383502994898 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383502996302 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383502996437 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503008274 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503011043 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503012570 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503012705 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503016133 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503016460 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383503028069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503031881 -started,bundle,org.eclipse.cdt.codan.checkers.ui,1.0.0.201202111925,"org.eclipse.cdt.codan.checkers.ui",1383503072664 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503080719 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv deleted file mode 100644 index b1db2da..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload6.csv +++ /dev/null @@ -1,301 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503085706 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503086817 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503087654 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503087991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503093369 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503094047 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383503097140 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503104049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503106007 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503107746 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503109282 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503138239 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503146336 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503153853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503154704 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503161199 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503163974 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503164305 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503169040 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503178336 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503181000 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503184114 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503186246 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503186503 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503191823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503192757 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503193809 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503194388 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503194655 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503198233 -executed,command,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.edit.text.shiftLeft",1383503201865 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503202740 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503206128 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503469823 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503505260 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383503509836 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383503512092 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383503512093 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503570667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503603324 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503612030 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503712289 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383503744172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503745518 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503753643 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383503772625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383503774337 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503774730 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503787032 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503787866 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503797096 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503822412 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383503832595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383503839205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503840513 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383503869090 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383503876143 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504379098 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504394423 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504399700 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504400189 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504404017 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504405166 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504413605 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504635150 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504638540 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504656237 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383504666902 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383504670368 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504672603 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504749636 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383504751205 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383504753456 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504755426 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504758172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504762099 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504763011 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504778502 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504782485 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504789987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504812524 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504814095 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504820803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504833409 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504837481 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504841582 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504855375 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504863988 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504865436 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504876664 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504880288 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504881826 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504885812 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504891753 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504904976 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504907994 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504908872 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504932211 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383504941211 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383504942953 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505095933 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505132594 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505134729 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505186434 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505189589 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505196493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505217372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505218268 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505224518 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505228789 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383505289185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505289879 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505291838 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505293791 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505295780 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505297150 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505298446 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505299977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505311968 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505314225 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505315861 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505366745 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505368052 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505369683 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505376704 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505382914 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505424017 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505433218 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505451136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505452395 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505461573 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505473610 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505486122 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505492793 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505493433 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505493777 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505500020 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505507117 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505528269 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505534709 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505539608 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505561016 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505561540 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505562317 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505566031 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505566380 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505567182 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505573737 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505742236 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383505778758 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505779355 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505780579 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505783034 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505783835 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505784508 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505784724 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505784908 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505785069 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505785236 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505785436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505790328 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505795559 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505797432 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505801423 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505803384 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505808920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383505810543 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505820231 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505826882 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383505832958 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505833954 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505834906 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505835523 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505836099 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505836586 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505837099 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383505837667 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505838797 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505852016 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505864953 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505871604 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505872994 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383505876356 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505880669 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505904198 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505925139 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505929022 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505950256 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383505995017 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506007232 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506008536 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506012070 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506013984 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506020220 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506020907 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506025803 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506026225 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506027709 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506033662 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506037911 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506041330 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506073545 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506081557 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506096905 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506098484 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506100258 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506102652 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506104119 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506105686 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506106244 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506107906 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506113571 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506117803 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506122059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506122859 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506123569 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506133032 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506145035 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506146510 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506170147 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506175200 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506179805 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506194811 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506195892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506226606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506227007 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506228118 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506235167 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506240568 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506247978 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506249146 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506270258 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383506272635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383506275560 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506279559 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506294957 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506297409 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506297960 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506303825 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506308601 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506317339 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506319422 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506320084 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506320615 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506327512 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506349064 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383506352858 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383506355476 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506356602 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383506360871 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506371158 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506377420 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506387719 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506393606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506400547 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506403058 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506408569 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506409339 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506664761 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506677335 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506682439 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506687839 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506689217 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506796310 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383506798471 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383506799349 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383506803625 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383506803769 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506807709 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506809030 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506817916 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506850832 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506860737 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506866109 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506869196 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506874787 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383506891806 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506893866 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506959606 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506967289 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506972002 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506976669 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506984491 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506985295 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506987333 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383506998313 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507007920 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507017800 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507017983 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507018247 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507021189 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507022922 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507041628 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507045727 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507060091 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507074497 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507077562 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507092266 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507107743 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507121931 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv deleted file mode 100644 index 308a7ed..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload7.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507123123 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507130413 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507137921 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507145080 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507150207 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507151860 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507271582 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507286411 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507287845 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507299174 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507302877 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507303546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507305498 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507306307 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507307856 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507310934 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507312882 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507356584 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507363833 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507367265 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507371074 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507375073 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507389519 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507396480 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507397504 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507402320 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507403882 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507412265 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507421435 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507441060 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507441637 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507445781 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507446365 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507451065 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507451867 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507483724 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507485394 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507486984 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507494491 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507496199 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507525502 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507533751 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507547113 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507550464 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507551516 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507554597 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507556519 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507562947 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507569176 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507576011 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507592274 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507594523 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507595706 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507599702 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507601166 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507605600 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507606559 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507613366 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507629810 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507635154 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507636510 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507637753 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507644482 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507655930 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507659876 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507660541 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507666476 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507670377 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507671930 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507674122 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507676558 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507685588 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507687254 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507708487 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507710086 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507717893 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507728688 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507730526 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507732064 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507737260 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507754466 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755167 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755206 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755247 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755286 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755327 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755408 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755595 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507755778 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507756045 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507760600 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507784980 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507785234 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507785410 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507785586 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507787046 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507822128 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507823700 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507853824 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507859328 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507861699 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507871052 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507871596 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507872044 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507872460 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507872884 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507873412 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507874599 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507883982 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507924767 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507928657 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507948271 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507949347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507954985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507960857 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507961041 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507961209 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507961369 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507961537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507961985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507963593 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383507964985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507966239 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383507983200 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383507986387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507986741 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383507990341 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383507994031 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507995954 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383507996327 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508007879 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508010237 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508011855 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508013212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508013432 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508014726 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508016374 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508017719 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508019317 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508019716 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508020288 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508020962 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508041987 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.window.preferences",1383508064242 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508064248 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508074184 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508074294 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508075114 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508080777 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508080936 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508081256 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508081424 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508082356 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508096584 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508098154 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508098508 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508103001 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508216302 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508225058 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508376927 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508378737 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383508412700 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383508421124 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383508423449 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508440634 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508443851 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508445552 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508445911 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508449750 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508458239 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508460036 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508460203 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508461663 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508464867 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508464881 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508483295 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508528909 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508539785 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508543056 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508545155 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508545516 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508546746 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508564247 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508564262 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508576855 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508580708 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508586253 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508587892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508588054 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508591558 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508613045 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508613059 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508637324 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508638634 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508638783 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508639841 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508692322 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508692335 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383508694098 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383508696047 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508698476 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508698644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508698796 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508698964 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508701264 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508703804 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508705485 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508705837 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508708089 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508720934 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508720947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508728849 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508730474 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508731949 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508731960 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508733148 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508733510 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508735301 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508744575 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508744589 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508759178 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508763072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383508772697 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383508773623 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383508776371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383508777376 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383508779161 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508780684 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508781045 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508782129 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508797690 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383508797703 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508805993 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508813393 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508853702 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508858958 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383508865482 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510635565 -executed,command,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.edit.text.c.toggle.comment",1383510661157 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383510666453 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383510673896 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510675694 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510676050 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510678349 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510704507 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383510707386 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383510708127 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383510708779 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383510710745 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510712451 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510712765 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510713722 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510738283 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383510738301 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510765077 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510775616 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383510787524 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383510792864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383510797684 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383510799371 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510800768 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510801122 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510802923 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510810914 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383510810928 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383510861819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383510864289 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383510875491 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383510876368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383510889027 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383510889745 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383510893093 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383510912036 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload8.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload8.csv deleted file mode 100644 index 4acb881..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload8.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383510913708 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510915278 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510915585 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510919375 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383510959571 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383510959594 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383510972905 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383510995005 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383510995324 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511007154 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383511008450 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511009782 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511010089 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511015676 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511018909 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511018925 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511029873 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511035858 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383511037362 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511038815 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511039134 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511040465 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511072911 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511072926 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383511088949 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511094486 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511094905 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383511096526 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511098043 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511098355 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511099732 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511104193 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511105711 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511105863 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511107262 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511157468 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511157484 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511162410 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511162445 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511166092 -closed,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511166092 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383511180407 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383511180683 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383511184985 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511187493 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511193853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383511195692 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511197733 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511201510 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383511210404 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511211136 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383511212653 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511214262 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511214625 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511216385 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511273768 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383511273788 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383511275292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383511276109 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383511278293 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383511278983 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511282890 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511284208 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383511284218 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511285714 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511286021 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511287350 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511819418 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511822161 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511825729 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511826212 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511862489 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511866552 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511866694 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511872514 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511875458 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511877889 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511881708 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383511906043 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512008225 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512017036 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512019627 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.cut",1383512021761 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512022695 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383512024368 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512025097 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512026848 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512028518 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512028840 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512030883 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512070401 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512070418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512073131 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512074790 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512076384 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512076735 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512078553 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512104117 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512105237 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512126350 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512126367 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512129225 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512152191 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512153456 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512153804 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512154267 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512184788 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512195822 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512215971 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512217051 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512237352 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512238802 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512240274 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512240636 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512243873 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512281273 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512281289 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512284340 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512284491 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512284901 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512285059 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512285584 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512315793 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512317671 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512319107 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512319414 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512323602 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512323745 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512325024 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512372385 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512372402 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383512374097 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383512377285 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512387037 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512388543 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512389892 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512390251 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512391415 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512445236 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512447895 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512448053 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512449486 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512496738 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512496756 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512497735 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383512499117 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512499415 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512500972 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512502283 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512502692 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512504135 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512517311 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512517337 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383512521258 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383512522691 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512524486 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512524999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512525866 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512556400 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512560940 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512632889 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512637590 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512641130 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512645373 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512651312 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512654286 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512654591 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512656544 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512657457 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512657513 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512658692 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512662714 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512696779 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383512696800 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512714048 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512882998 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383512891296 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513278939 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383513312723 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383513314466 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513316223 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513316536 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513318042 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513319089 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513321096 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513325869 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513327726 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513327881 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513330291 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513330861 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513331210 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513340920 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513341953 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513376392 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383513376407 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383513377781 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383513380801 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383513383583 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513385112 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513385407 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383513387198 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383516407982 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383516408508 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518379335 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518389274 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518411293 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518423752 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.help.aboutAction",1383518428089 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518428097 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518433967 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518447180 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383518450634 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519230590 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519233497 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519233644 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519237667 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519240422 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519242726 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519245638 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519253940 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519257982 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519259651 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519260868 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519262839 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519262999 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519266914 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519269655 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519271488 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519272327 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519272384 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519273080 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519278090 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519302635 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519302653 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519308248 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519310828 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519316372 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519317132 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519318879 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519324771 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519326046 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519327039 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519327779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519330177 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519331166 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519331778 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519337281 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519338749 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519339050 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519341116 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519351932 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519351947 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519354008 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519355679 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519357474 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519357775 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519358959 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519378110 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519378126 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519379504 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519505111 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519521352 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519548908 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519555672 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519559450 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519560870 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383519562939 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519563999 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519565529 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519566975 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519567281 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519568284 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519575354 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519575371 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519580345 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload9.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload9.csv deleted file mode 100644 index ce33d56..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/upload9.csv +++ /dev/null @@ -1,276 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519581620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519583073 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519583373 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519584408 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519599836 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519599853 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519601063 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519602316 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519603632 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519603930 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519604749 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519612571 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519612585 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519614654 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519658115 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519668653 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519672360 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519678635 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519683937 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519688903 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383519690213 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519693207 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383519695347 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519695678 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519704055 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383519706159 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710049 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710240 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710401 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710553 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519710897 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519713817 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519713969 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519714129 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519714304 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519715833 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519715977 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716121 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716257 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716377 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716537 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716657 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716801 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519716944 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519717153 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519717369 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519717949 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519734837 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519736366 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519737716 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519738071 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519741793 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519760136 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519760151 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519761762 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519762333 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519763888 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519765569 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519765924 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519766826 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519789628 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519789644 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519791999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519794438 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519850362 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519864182 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383519864939 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519867488 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519871934 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519877643 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519880805 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519882644 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519885473 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519886573 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519887931 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519889167 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519889470 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519890749 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519905569 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519905584 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383519909326 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519921380 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383519922418 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383519922797 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383519925492 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519926744 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519927045 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519928573 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519944008 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383519944026 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383519950011 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520068114 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520075654 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520198276 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520200856 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520204426 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520228626 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383520232715 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383520233968 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383520267603 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383520269561 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520278234 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520280129 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520281853 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520282153 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520283273 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520308705 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520308721 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520309759 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520309997 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520314865 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520315053 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520316101 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520317763 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520319124 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520319430 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520320078 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520356623 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520356642 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383520360779 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383520363301 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520365981 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371021 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371180 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371308 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371436 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371557 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371692 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371812 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520371940 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520372076 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520372461 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520373346 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520375305 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520376769 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520377062 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520378500 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520408958 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520408978 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520418898 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520424987 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520429321 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520429336 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520430616 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520430915 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520432327 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520443187 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520443202 -executed,command,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.edit.text.c.toggle.comment",1383520452748 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520454051 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520456995 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520458421 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520458770 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520466595 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520471536 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520471554 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520488929 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520490316 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520490418 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520491676 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520503791 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520503807 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383520505546 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383520511279 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516172 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516832 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516871 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516911 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516952 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520516991 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520517031 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520517072 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520517112 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520517387 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383520517587 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520518345 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520521001 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383520522369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520524130 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520524470 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520525072 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520632334 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383520632350 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520693393 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520697432 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520703434 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520717341 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520720304 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520721040 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520728525 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520730382 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520735544 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520738039 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520739858 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520744752 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520747314 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520748783 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520751442 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520759506 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520764972 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520766620 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520770073 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520770914 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520774054 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520775398 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520780118 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520783932 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383520787687 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520794674 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520850092 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520852447 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520908237 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383520911519 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383520913395 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520915486 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520916563 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520916972 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520917619 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520918176 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520918918 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520921991 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520993110 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383520999715 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521011891 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383521015334 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383521016570 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521018928 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521021776 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521021935 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521024112 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521024272 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521025445 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521030095 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521080277 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521086593 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521086864 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521088960 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521091866 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521096274 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521103292 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521106714 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521107385 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521111972 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521113570 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521114144 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521131293 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521160299 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521166720 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521212075 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521472665 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521498859 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521500223 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521507228 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521508517 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521511386 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521512959 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521514979 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521517567 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521523330 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521524829 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521527618 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383521566227 -opened,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521566311 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521566343 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1383521566353 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521566819 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.copy",1383521573371 -activated,editor,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui.editor.CEditor",1383521578764 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.paste",1383521579798 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521580746 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521603185 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.delete",1383521642638 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.save",1383521644105 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1383521647906 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv b/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv deleted file mode 100644 index e1dec4b..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.epp.usagedata.recording/usagedata.csv +++ /dev/null @@ -1,201 +0,0 @@ -what,kind,bundleId,bundleVersion,description,time -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1395610321064 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1395610321064 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1395610321064 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1395610321064 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1395610321064 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1395610321064 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1395610321064 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1395610321064 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1395610321064 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1395610321064 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1395610321064 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1395610321064 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1395610321064 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1395610321064 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1395610321065 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1395610321065 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1395610321065 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1395610321065 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1395610321065 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1395610321065 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1395610321065 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1395610321065 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1395610321065 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1395610321065 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1395610321065 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1395610321065 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1395610321065 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1395610321065 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1395610321065 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1395610321065 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1395610321065 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1395610321066 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1395610321066 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1395610321066 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1395610321066 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1395610321066 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1395610321066 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1395610321066 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1395610321066 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1395610321066 -os,sysinfo,,,"linux",1395610321068 -arch,sysinfo,,,"x86",1395610321068 -ws,sysinfo,,,"gtk",1395610321068 -locale,sysinfo,,,"en_US",1395610321068 -processors,sysinfo,,,"8",1395610321069 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1395610321069 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1395610321069 -java.specification.name,sysinfo,,,"Java Platform API Specification",1395610321069 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1395610321069 -java.specification.version,sysinfo,,,"1.6",1395610321069 -activated,perspective,com.altera.sbtgui.ui,,"com.altera.sbtgui.ui.cPerspective",1396179388332 -started,bundle,org.eclipse.osgi,3.7.2.v20120110-1415,"org.eclipse.osgi",1396179388333 -started,bundle,org.eclipse.equinox.simpleconfigurator,1.0.200.v20110815-1438,"org.eclipse.equinox.simpleconfigurator",1396179388333 -started,bundle,com.ibm.icu,4.4.2.v20110823,"com.ibm.icu",1396179388333 -started,bundle,org.eclipse.cdt.core,5.3.2.201202111925,"org.eclipse.cdt.core",1396179388333 -started,bundle,org.eclipse.cdt.make.core,7.1.2.201202111925,"org.eclipse.cdt.make.core",1396179388333 -started,bundle,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.ui",1396179388333 -started,bundle,org.eclipse.cdt.managedbuilder.core,8.0.2.201202111925,"org.eclipse.cdt.managedbuilder.core",1396179388333 -started,bundle,org.eclipse.cdt.msw.build,1.0.0.201202111925,"org.eclipse.cdt.msw.build",1396179388333 -started,bundle,org.eclipse.cdt.ui,5.3.2.201202111925,"org.eclipse.cdt.ui",1396179388333 -started,bundle,org.eclipse.compare.core,3.5.200.I20110208-0800,"org.eclipse.compare.core",1396179388334 -started,bundle,org.eclipse.core.contenttype,3.4.100.v20110423-0524,"org.eclipse.core.contenttype",1396179388334 -started,bundle,org.eclipse.core.databinding.observable,1.4.0.I20110222-0800,"org.eclipse.core.databinding.observable",1396179388334 -started,bundle,org.eclipse.core.expressions,3.4.300.v20110228,"org.eclipse.core.expressions",1396179388334 -started,bundle,org.eclipse.core.filebuffers,3.5.200.v20110928-1504,"org.eclipse.core.filebuffers",1396179388334 -started,bundle,org.eclipse.core.filesystem,1.3.100.v20110423-0524,"org.eclipse.core.filesystem",1396179388334 -started,bundle,org.eclipse.core.jobs,3.5.101.v20120113-1953,"org.eclipse.core.jobs",1396179388334 -started,bundle,org.eclipse.core.net,1.2.100.I20110511-0800,"org.eclipse.core.net",1396179388335 -started,bundle,org.eclipse.core.resources,3.7.101.v20120125-1505,"org.eclipse.core.resources",1396179388335 -started,bundle,org.eclipse.core.runtime,3.7.0.v20110110,"org.eclipse.core.runtime",1396179388335 -started,bundle,org.eclipse.core.runtime.compatibility,3.2.100.v20100505,"org.eclipse.core.runtime.compatibility",1396179388335 -started,bundle,org.eclipse.core.runtime.compatibility.auth,3.2.200.v20110110,"org.eclipse.core.runtime.compatibility.auth",1396179388335 -started,bundle,org.eclipse.core.variables,3.2.500.v20110928-1503,"org.eclipse.core.variables",1396179388335 -started,bundle,org.eclipse.debug.core,3.7.1.v20111129-2031,"org.eclipse.debug.core",1396179388335 -started,bundle,org.eclipse.egit.core,1.3.0.201202151440-r,"org.eclipse.egit.core",1396179388335 -started,bundle,org.eclipse.egit.ui,1.3.0.201202151440-r,"org.eclipse.egit.ui",1396179388335 -started,bundle,org.eclipse.epp.mpc.ui,1.1.1.I20110907-0947,"org.eclipse.epp.mpc.ui",1396179388335 -started,bundle,org.eclipse.epp.usagedata.gathering,1.3.1.R201106061540,"org.eclipse.epp.usagedata.gathering",1396179388335 -started,bundle,org.eclipse.epp.usagedata.recording,1.3.1.R201106061540,"org.eclipse.epp.usagedata.recording",1396179388335 -started,bundle,org.eclipse.equinox.app,1.3.100.v20110321,"org.eclipse.equinox.app",1396179388335 -started,bundle,org.eclipse.equinox.common,3.6.0.v20110523,"org.eclipse.equinox.common",1396179388335 -started,bundle,org.eclipse.equinox.ds,1.3.1.R37x_v20110701,"org.eclipse.equinox.ds",1396179388336 -started,bundle,org.eclipse.equinox.event,1.2.100.v20110502,"org.eclipse.equinox.event",1396179388336 -started,bundle,org.eclipse.equinox.p2.core,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.core",1396179388336 -started,bundle,org.eclipse.equinox.p2.directorywatcher,1.0.300.v20110815-1419,"org.eclipse.equinox.p2.directorywatcher",1396179388337 -started,bundle,org.eclipse.equinox.p2.engine,2.1.1.R37x_v20111003,"org.eclipse.equinox.p2.engine",1396179388337 -started,bundle,org.eclipse.equinox.p2.metadata,2.1.0.v20110815-1419,"org.eclipse.equinox.p2.metadata",1396179388337 -started,bundle,org.eclipse.equinox.p2.metadata.repository,1.2.0.v20110815-1419,"org.eclipse.equinox.p2.metadata.repository",1396179388337 -started,bundle,org.eclipse.equinox.p2.operations,2.1.1.R37x_v20111111,"org.eclipse.equinox.p2.operations",1396179388337 -started,bundle,org.eclipse.equinox.p2.reconciler.dropins,1.1.100.v20110815-1419,"org.eclipse.equinox.p2.reconciler.dropins",1396179388337 -started,bundle,org.eclipse.equinox.p2.repository,2.1.1.v20120113-1346,"org.eclipse.equinox.p2.repository",1396179388338 -started,bundle,org.eclipse.equinox.p2.ui.sdk.scheduler,1.0.100.v20110815-1419,"org.eclipse.equinox.p2.ui.sdk.scheduler",1396179388338 -started,bundle,org.eclipse.equinox.p2.updatechecker,1.1.200.v20110815-1419,"org.eclipse.equinox.p2.updatechecker",1396179388338 -started,bundle,org.eclipse.equinox.preferences,3.4.2.v20120111-2020,"org.eclipse.equinox.preferences",1396179388338 -started,bundle,org.eclipse.equinox.registry,3.5.101.R37x_v20110810-1611,"org.eclipse.equinox.registry",1396179388338 -started,bundle,org.eclipse.equinox.security,1.1.1.R37x_v20110822-1018,"org.eclipse.equinox.security",1396179388338 -started,bundle,org.eclipse.equinox.util,1.0.300.v20110502,"org.eclipse.equinox.util",1396179388338 -started,bundle,org.eclipse.help,3.5.100.v20110426,"org.eclipse.help",1396179388338 -started,bundle,org.eclipse.jface,3.7.0.v20110928-1505,"org.eclipse.jface",1396179388339 -started,bundle,org.eclipse.jgit,1.3.0.201202151440-r,"org.eclipse.jgit",1396179388339 -started,bundle,org.eclipse.jsch.core,1.1.300.I20110514-0800,"org.eclipse.jsch.core",1396179388339 -started,bundle,org.eclipse.linuxtools.cdt.autotools.core,1.0.2.201202152032,"org.eclipse.linuxtools.cdt.autotools.core",1396179388339 -started,bundle,org.eclipse.ltk.core.refactoring,3.5.201.r372_v20111101-0700,"org.eclipse.ltk.core.refactoring",1396179388339 -started,bundle,org.eclipse.ltk.ui.refactoring,3.6.0.v20110928-1453,"org.eclipse.ltk.ui.refactoring",1396179388339 -started,bundle,org.eclipse.mylyn.bugzilla.core,3.6.5.v20120123-0100,"org.eclipse.mylyn.bugzilla.core",1396179388339 -started,bundle,org.eclipse.mylyn.bugzilla.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.bugzilla.ui",1396179388339 -started,bundle,org.eclipse.mylyn.commons.identity,0.8.0.v20110608-1400,"org.eclipse.mylyn.commons.identity",1396179388339 -started,bundle,org.eclipse.mylyn.commons.net,3.6.0.v20110608-1400,"org.eclipse.mylyn.commons.net",1396179388339 -started,bundle,org.eclipse.mylyn.commons.ui,3.6.1.v20110720-0100,"org.eclipse.mylyn.commons.ui",1396179388339 -started,bundle,org.eclipse.mylyn.context.core,3.6.1.v20110720-0100,"org.eclipse.mylyn.context.core",1396179388339 -started,bundle,org.eclipse.mylyn.context.ui,3.6.1.v20120112-0100,"org.eclipse.mylyn.context.ui",1396179388339 -started,bundle,org.eclipse.mylyn.monitor.ui,3.6.0.v20110608-1400,"org.eclipse.mylyn.monitor.ui",1396179388339 -started,bundle,org.eclipse.mylyn.tasks.ui,3.6.5.v20120215-0100,"org.eclipse.mylyn.tasks.ui",1396179388339 -started,bundle,org.eclipse.mylyn.team.ui,3.6.1.v20110825-0100,"org.eclipse.mylyn.team.ui",1396179388340 -started,bundle,org.eclipse.search,3.7.0.v20110928-1504,"org.eclipse.search",1396179388340 -started,bundle,org.eclipse.team.core,3.6.0.I20110525-0800,"org.eclipse.team.core",1396179388340 -started,bundle,org.eclipse.team.cvs.core,3.3.400.I20110510-0800,"org.eclipse.team.cvs.core",1396179388340 -started,bundle,org.eclipse.team.cvs.ui,3.3.401.v20120126-1227,"org.eclipse.team.cvs.ui",1396179388340 -started,bundle,org.eclipse.team.ui,3.6.101.R37x_v20111109-0800,"org.eclipse.team.ui",1396179388340 -started,bundle,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui",1396179388340 -started,bundle,org.eclipse.ui.console,3.5.100.v20111007_r372,"org.eclipse.ui.console",1396179388340 -started,bundle,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.editors",1396179388340 -started,bundle,org.eclipse.ui.forms,3.5.101.v20111011-1919,"org.eclipse.ui.forms",1396179388340 -started,bundle,org.eclipse.ui.ide,3.7.0.v20110928-1505,"org.eclipse.ui.ide",1396179388340 -started,bundle,org.eclipse.ui.navigator,3.5.101.v20120106-1355,"org.eclipse.ui.navigator",1396179388340 -started,bundle,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.resources",1396179388340 -started,bundle,org.eclipse.ui.net,1.2.100.v20111208-1155,"org.eclipse.ui.net",1396179388340 -started,bundle,org.eclipse.ui.views,3.6.0.v20110928-1505,"org.eclipse.ui.views",1396179388340 -started,bundle,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"org.eclipse.ui.workbench",1396179388340 -started,bundle,org.eclipse.ui.workbench.texteditor,3.7.0.v20110928-1504,"org.eclipse.ui.workbench.texteditor",1396179388340 -started,bundle,org.eclipse.update.configurator,3.3.100.v20100512,"org.eclipse.update.configurator",1396179388340 -started,bundle,org.eclipse.update.core,3.2.500.v20110330,"org.eclipse.update.core",1396179388340 -started,bundle,org.eclipse.update.scheduler,3.2.300.v20100512,"org.eclipse.update.scheduler",1396179388341 -started,bundle,com.altera.sbtgui.core,13.1.0.162,"com.altera.sbtgui.core",1396179388341 -started,bundle,com.altera.sbtgui.integration,13.1.0.162,"com.altera.sbtgui.integration",1396179388341 -started,bundle,com.altera.sbtgui.launch,13.1.0.162,"com.altera.sbtgui.launch",1396179388341 -started,bundle,com.altera.sbtgui.project,13.1.0.162,"com.altera.sbtgui.project",1396179388341 -started,bundle,com.altera.systemconsole,13.1.0.162,"com.altera.systemconsole",1396179388341 -started,bundle,com.altera.systemconsole.designs.plugin,13.1.0.162,"com.altera.systemconsole.designs.plugin",1396179388341 -started,bundle,com.altera.utilities,13.1.0.162,"com.altera.utilities",1396179388341 -os,sysinfo,,,"linux",1396179388343 -arch,sysinfo,,,"x86",1396179388343 -ws,sysinfo,,,"gtk",1396179388343 -locale,sysinfo,,,"en_US",1396179388343 -processors,sysinfo,,,"8",1396179388343 -java.runtime.name,sysinfo,,,"Java(TM) SE Runtime Environment",1396179388343 -java.runtime.version,sysinfo,,,"1.6.0_23-b05",1396179388343 -java.specification.name,sysinfo,,,"Java Platform API Specification",1396179388343 -java.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1396179388343 -java.specification.version,sysinfo,,,"1.6",1396179388343 -java.vendor,sysinfo,,,"Sun Microsystems Inc.",1396179388343 -java.version,sysinfo,,,"1.6.0_23",1396179388343 -java.vm.info,sysinfo,,,"mixed mode",1396179388343 -java.vm.name,sysinfo,,,"Java HotSpot(TM) Server VM",1396179388343 -java.vm.specification.name,sysinfo,,,"Java Virtual Machine Specification",1396179388343 -java.vm.specification.vendor,sysinfo,,,"Sun Microsystems Inc.",1396179388343 -java.vm.specification.version,sysinfo,,,"1.0",1396179388343 -java.vm.vendor,sysinfo,,,"Sun Microsystems Inc.",1396179388343 -java.vm.version,sysinfo,,,"19.0-b09",1396179388343 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1396179389348 -started,bundle,org.eclipse.epp.usagedata.ui,1.3.1.R201106061540,"org.eclipse.epp.usagedata.ui",1396179389348 -error,log,,,"Unhandled event loop exception",1396179389458 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1396179393401 -started,bundle,org.eclipse.compare,3.5.202.R37x_v20111109-0800,"org.eclipse.compare",1396179393826 -started,bundle,org.eclipse.debug.ui,3.7.102.v20111129-1423_r372,"org.eclipse.debug.ui",1396179401058 -started,bundle,org.eclipse.cdt.dsf,2.2.0.201202111925,"org.eclipse.cdt.dsf",1396179401062 -started,bundle,org.eclipse.cdt.dsf.gdb,4.0.2.201202111925,"org.eclipse.cdt.dsf.gdb",1396179401062 -started,bundle,org.eclipse.cdt.dsf.gdb.ui,2.2.1.201202111925,"org.eclipse.cdt.dsf.gdb.ui",1396179401062 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179401102 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179403743 -opened,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1396179413478 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1396179413522 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1396179413535 -activated,editor,org.eclipse.ui.editors,3.7.0.v20110928-1504,"org.eclipse.ui.DefaultTextEditor",1396179414220 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1396179414816 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1396179422369 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179422375 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179432035 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1396179436567 -opened,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1396179439907 -activated,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1396179439958 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1396179439969 -activated,editor,org.eclipse.cdt.make.ui,7.1.2.201202111925,"org.eclipse.cdt.make.editor",1396179440370 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.file.refresh",1396179441136 -executed,command,org.eclipse.ui,3.7.0.v20110928-1505,"org.eclipse.ui.edit.findReplace",1396179445676 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179445682 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179450023 -activated,view,org.eclipse.ui.navigator.resources,3.4.300.v20110928-1505,"org.eclipse.ui.navigator.ProjectExplorer",1396179452718 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179457382 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179462939 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179465802 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179465999 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179466554 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179466789 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179469511 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179470731 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179470773 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179471395 -deactivated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396179476224 -activated,workbench,org.eclipse.ui.workbench,3.7.1.v20120104-1859,"",1396184335228 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.history b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.history deleted file mode 100644 index 80a647d..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.history +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.index b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.index deleted file mode 100644 index 34c41f2..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/.workspace/2013/11/44/refactorings.index +++ /dev/null @@ -1,4 +0,0 @@ -1383424805712 Delete resource 'exe/readme.txt' -1383424812736 Delete resource 'exe/create-this-app' -1383424832042 Delete resource 'exe/system' -1383424836501 Delete resource 'exe/hello_world_small.c' diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index 27eb404..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.search/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.search/dialog_settings.xml deleted file mode 100644 index 5138536..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.search/dialog_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - -
-
- -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.team.cvs.core/.running b/syn/soc/firmware/.metadata/.plugins/org.eclipse.team.cvs.core/.running deleted file mode 100644 index e69de29..0000000 diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml deleted file mode 100644 index 50f1edb..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml deleted file mode 100644 index 258dbd0..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml +++ /dev/null @@ -1,30 +0,0 @@ - -
-
- - - - - -
-
- - - - - - - - - - - - - - - - - - -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index b962468..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml deleted file mode 100644 index 6f7a8d7..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +++ /dev/null @@ -1,514 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index 189e2ea..0000000 --- a/syn/soc/firmware/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/syn/soc/firmware/.metadata/version.ini b/syn/soc/firmware/.metadata/version.ini deleted file mode 100644 index c51ff74..0000000 --- a/syn/soc/firmware/.metadata/version.ini +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.core.runtime=1 \ No newline at end of file